ASP.NET - Publishing a web site to IIS - asp.net

What is the difference between publishing a website to {localdrive}\inetpub\wwwroot and anywhere else on the web server e.g. C:\Website.
I have noticed that I am always left with a directory and a website in the IIS console if I publish to {localdrive}\inetpub\wwwroot.
After reading articles on MSDN, I am still unclear of the difference. I realise that there is probably a simpe answer to this, but I cannot find it.

The web path / is already mapped to c:\inetpub\wwwroot, so /abc is mapped to c:\inetpub\wwwroot\abc automatically.
When you publish to c:\website, you need to set up a virtual path manually.

Nothing too much as your website path in IIS can point to any directory. However, that being said always double check your directory permissions and security settings. In addition, I guess if a hacker did compromised your webserver... the default c:\inetpub\wwwroot is well known.
And just for good measure in case you are having issues - check out the Aspnet_regiis.exe tool on MSDN as it usually solves a lot of issues for folks.

{localdrive}\inetpub\wwwroot is usually used for the default web site that comes with IIS.
Additional Microsoft products use the same directory and take advantage of the virtual directories that exist in the default site.
If this is your personal web site, or a web site you created from scratch, you can publish anywhere you want.
Before you publish, you need to make sure IIS knows where the directory will be, and you need to assign the correct permissions for that folder.

The default website in IIS is mapped to C:\inetpub\wwwroot by default, so publishing to wwwroot makes it easy to add applications as virtual directories.
However, you can publish wherever you like, and either point a virtual directory or new website at your publication location. You simply need to make sure user the App Pool is running as (usually IUSR under IIS7, IUSR_MachineName under previous versions) has read/execute permissions on the folder you are publishing to.

Although they say Virtual Directory created by default for your website in wwwroot and you don't have to configure it again. Many times I found we still have to go there and click on Remove and then click on Create button again :)
Thus it is almost no problem if you create your website outside wwwroot, only difference outside you have to give full path of VD and inside you have to click Remove and then Create button

The problem I had was different from all of the above. I was trying to publish in "C:\inetpub\wwwroot" and the publish failed every time. Than i changed the publish folder to another and it worked. When I launched visual studio as administrator I could copy to C:\inetpub\wwwroot also without problems

Related

Sitecore permissions issue

I have a sitecore site running on .NET 4.0 and IIS 7.5 on Windows 7 machine.
While setting up sitecore, I had installed only the sitecore client and then set up IIS7. I think some permissions have got messed up because of that.
Whenever I try to change a code file in my website in Visual Studio, it gives me a message that I don't have any permissions to modify the files. I can overwrite the existing one, however, this is not normal.
Also, I have ApplicationPoolIdentity set as my Identity for my Application Pool. Whenever I try to go to sitecore desktop it doesn't work, however I can go to content editor upon login. Even after logging in, if I try to go to sitecore desktop mode like /sitecore/shell/default.aspx, the page never loads and the progress wheel just keeps spinning.
It happens in FF, Chrome and IE so it can't be a browser issue.
I checked the permissions of various folder and they all look fine. System, Administrator and Local computer user have full control on the website folder and the files and folders underneath it.
It would be great if someone can help in trying to figure out the right configuration and settings for my website folder.
Firstly, as per the best practice of installing Sitecore, we should set the identity as NetworkService.
So please do 2 things:
Change the Identity in Application Pool as Network Service
Make sure that Website and all its descendants + the Data Folder and all its descendants have Read & Write access for Network Service.
Mostly this should work.
Regards,
Varun Shringarpure
Does IUSR have "Read" permissions on the \Website folder and on all descendants?
Additionally, you may want to look at the Sitecore logs under the \Data\logs folder. You may be having a database connectivity issue that may show up there.

What is needed to run a webapp in IIS with absolute paths

I previously made my "Web Applications" type of projects inside some individual directories
and have been making "Web Site" types (based on visual studio's project types") inside IIS.
Although It should be a repetitive task but I want to know the most usual needed steps for doing so
What I need :
Access to the media with absolute paths
As an example
I placed my project inside "IIS Root folder/ProjectBase/Project"
and convert that to Web Application via IIS.
It seems that I couldn't access to my stored media files within the Project Folder.
What is the exact problem in this case ? Is it related to folder permissions of the "Project Folder" ?
Also should I make the "ProjectBase" Folder also a virtual directory ?
the program is running via cassini,
At first I want to have access to my Project based files via "absolute paths"
As a conclusion
Having "Web Application" Type running with possibility to access to its files via absolute paths.
It should be an easy task for the Pros, but, anyway I'm in hurry and needed good-fast advice.
thanks in advance
Could be a file permissions issue. You can resolve that by going through IIS and setting the permissions on the folders. Grant read/write to the IIS user for that machine. If you're actually writing anything back you may need to grant access to Network_Services as well.
Also you can look at adding a virtual directory to the website in IIS and point that to the actual physical directory on the box. That has solved some file access issues for me in the past.

No access to files in iis7 mvc app - server 2008 r2

I've just installed windows server 2008 r2 along with visual studio and dropbox. I'm using it as a VM for development and dropbox helps me keep my files in sync with other machines.
I've got my site set up in IIS but I'm getting an access denied error when trying to view the site. I've had this before and to get around it in the past I've gone through and added the IIS_User account to the list of permissions to read/modify the files. I assume because the file's have been copied down with drop box the files don't have the necessary permissions. Here's the bugger, I can't batch update the files by modifying permissions on a folder, I'm having to do it right to the file level and even worse, one at a time! I can't have this.
I'm relatively new to 2008 r2 and IIS 7 so I have no idea what's happening here. Can someone explain what is going on and if there's an IIS/file permission setting I can update to resolve it at the top level folder?
I've tried adding anonymous permssions on the website in IIS and I've added permissions on the folder for IIS_User (even Everyone). I have an Administrator account and that's already set to allow me to read/write/modify the files.
This is typically the message I'm getting 'An error occurred loading a configuration file: Access to the path X is denied'.
This is happening on ascx & aspx files as well as config files.
Edits:
The site is visible when debugging from Visual Studio.
The site is operating in Full Trust (internal)
Please help, this is stopping me from working and driving me insane!
By default in IIS 7, websites run as the local system's network account (NetworkService), not as IIS_User.
To verify, in IIS Manager, select the Site in question, click Basic Settings... and check the Application Pool it is assigned to. Then go into Application Pools and check the Identity for that Application Pool. Make sure that user listed is in the ACL.
Adding Everyone to the ACL should work instead, but just in case I would suggest you check the above. Also of course make sure when you set the ACL to check the box for resetting inheritance on all subfolders, if that is appropriate for your application.
You could also try setting the identity of the application pool to a local (or domain) user you have created which has access to your application directory.
Hope that helps.
Regarding whether other identities would work for your app pool, that depends entirely on whether those identities have permissions to all the files and/or databases and other resources you application needs to access. Right now you have the application running under your user account, which is generally not recommended. IIS has your password cached, and if you change it, your application will stop working until you update the application pool configuration.
As far as setting NTFS permissions, it can get tricky. Once you have disabled permissions inheritance, that file or folder will need to be updated individually every time you need a permission change. The flip side of this is that you cannot remove inherited entries on an ACL, you can only add to them. However you can design a strategy that offers a baseline level of permission at the root of a file structure, and then add permissions to subfolders/files.
In order to check & reset inheritance on a folder, go into its properties, security tab, click advanced, then click Edit. You can see whether this folder inherits permissions from its parent, and optionally wipe out all subfolder/file permissions and enable inheritance on all child folders & files.
Hope this helps.

Is it safe to delete the "InetPub" folder?

Does anyone know if deleting the InetPub folder will hurt IIS or anything related?
I am using IIS 7.
IIS will create it again AFAIK.
As long as you go into the IIS configuration and change the default location from %SystemDrive%\InetPub to %SystemDrive%\www for each of the services (web, ftp) there shouldn't be any problems. Of course, you can't protect against other applications that might install stuff into that directory by default, instead of checking the configuration.
My recommendation? Don't change it -- it's not that hard to live with, and it reduces the confusion level for the next person who has to administrate the machine.
If you reconfigure IIS7 to use your new location, then there's no problem. Just test that the new location is working, before deleting the old location.
Change IIS7 Inetpub path
Open %windir%\system32\inetsrv\config\applicationhost.config and search for
%SystemDrive%\inetpub\wwwroot
Change the path.
Don't delete the folder or you will create a registry problem. However, if you do not want to use IIS, search the web for turning it off. You might want to check out "www.blackviper.com" because he lists all Operating System "services" (Not "Computer Services" - both are in Administrator Tools) with extra information for what you can and cannot disable to change to manual. If I recall correctly, he had some IIS info and how to turn it off.
it is safe to delete the inetpub it is only a cache.

global.asa where does it belong?

I'm moving some ASP code from one server to another. The location names are slightly different and I suspect that now the "global.asa" isn't getting called properly. The location is in c:\Inetpub\wwwroot\myApp.
It belongs in the root folder of your application. Also make sure that that folder is a application in the IIS manager. There is a textbox for application name, and right next to it a button "Create", if the folder isn't already an application.
Make sure that "myApp" in IIS is defined as an application. I would also check the .Net application mappings to make sure .Net is handling your requests.
The global.asa should be in the root of your virtual directory. Note that global.asa is used by asp not asp.net.
You can generally tell by looking at IIS Manager whether or not your directory is a virtual directory as it will not look like a yellow folder. If it does look like the typical yellow folder, right click the parent "Default Web Site" or whatever, and choose new virtual directory.
Alternatively, the global.asa can go in the root of the Web. Which is typically C:\inetpub\wwwroot if you are using the "Default Web Site"
For convenience, I want to keep in a subdirectory. Apparently, you have to designate that directory as an application. Here's a link that describes how:
http://www.calcaria.net/ASP/2006/04/globalasa-file-doesnt-work.html
Generally, I'm against the idea of files which are called auto-magically and not referred to in the code. If you are a noob like me, you can go off the rails for a while, before you track it down. I just lost a couple of hours on this silliness.

Resources