Web configuration file being accessed in the wrong folder - asp.net

I have deployed an asp.net website on a production server. It is working on my local but on the server I get this error:
An error occurred loading a configuration file: Failed to start
monitoring changes to
'E:\HostingSpaces\xxxxx\xxxxxx.xxxxxx.com\wwwroot\admin\web.config'
because access is denied
This looks to me that the app is looking for the web.config in the admin folder while it is obviously in the root.
How is this possible? How do I solve this problem?

IIS which is hosting ASP.NET is looking for a potential web.config file in every folder of your site, not just in the root folder.
This is because you may want to override certain settings for just one folder.
So you may have a web.config in admin but IIS hasn't got access to it, or IIS hasn't got access to the whole admin folder.
Check the permissions on that directory.

The problem is that the directory it has been deployed to does not have the correct read/write permissions for IIS to read the web.config.
Each website configured in IIS 6+ runs under a specific AppPool. That app pool runs under a specific user account, and it is that user account that needs read/write permissions to this directory.

Related

Missing site assets when no local\Users permission on the folder

I'm working on the Umbraco site (asp.net MVC) hosted on local Windows Server 2016+IIS10.
During regular template modification, I have experienced strange behavior - the site lost all of the assets hosted from local files. All the requests to cases or images were redirected to the login page. A few people reported similar behavior, commonly resolving it by permission checking. So did I - ensured that my pool user has granted full access to the folder and all its descendants. It was, so I removed it and applied it once again. Still no luck. I have copied the website files and created another web app in IIS - this one worked without any glitch.
Later, my co-worker found that the application folder is missing access permission for the local machine "Users" group. When we added it - the site is served without any issues.
The webserver is part of the corporate domain (AD) and the app pool user is a "service user".
Is it normal that it needs both - pool user and local "Users" permission?
Why is so?
It is normal. When the static file and the application are in same machine, the application needs higher permissions to read the static file.
When the application runs in IIS, it will use the identity of the application pool to read static files, and the default identity of the application pool is ApplicationPoolIdentity, with the lowest permissions.
The test in visual studio does not have this problem because IIS express runs the application with the same permissions as the administrator.

IIS: System.UnauthorizedAccessException: Access to the path

I have a website and it sits on the IIS Server and I have a folder on another server the file server. I have set the Virtual directory to the folder on the fileserver. This application both servers are on the same domain, but in the future I will have serves that are not on the same domain.
I have tried to set up local users on both machines and set up the app pool to use the local accounts and I get
System.UnauthorizedAccessException: Access to the path is denied.
and
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
I have set the virtual to connect as the local user and get the same error.
I have setup a domain user and then set the app pool to use the domain user and set to use pass through and when I test the settings in Directory Browsing it says everything is good but I get the same error from the webpage.
I have setup a domain user and then set the app pool to use the domain user and set to the connect as to the user and when I test the settings in Directory Browsing it says everything is good but I get the same error from the webpage.
I have set the apppool to use my login and it works with pass through permissions.
Is there something I am missing.
You need to set the folder permissions in your separate folder to give access to the "computer$" account of the server where your application is hosted.
See here: https://www.iis.net/learn/manage/configuring-security/application-pool-identities
application pool identities also use the machine account to access
network resources.
So in the server where you have your data files you should set the folder permissions to allow access to the machine name where your website is hosted.
I had this same challenge when deploying a web app using IIS on a Windows 2012 Server.
The issue was the App Pool Account did not have Full rights to the Website Root.
All I had to do was to go to the directory where the Website Root resides and then right-clicked on it. Next, I selected Security and then gave the IIS-Users group full access to the directory.
For me IIS-Users group contains all Users/App Pool Accounts that are created in IIS.
That's all.
I hope this helps
I have created a domain user specifically for the the virtual directory and it appears to work, but is this best practice?

Access Denied to different server on Virtual Directory in IIS

I setup an asp.net web application on IIS that I have setup several times for other clients but getting a strange permission issue on this one.
It's setup so the App Pool Identity is NetworkService and the folder being used has Network Service as a permitted user with full permissions. The folder can be browsed from the server the application is on and items added, edited and deleted.
But for a reason I cannot determine any time the application tries to access a file from the virtual directory I get 'Access is Denied'. I have checked permissions on the root folder of the actual application which also has Network Service and checked the virtual directory permissions use the identity as well, not sure what else to try?

The requested page cannot be accessed because the related configuration data for the page is invalid

I am getting this error when I try to run an ASP.NET application without a web.config file.
The requested page cannot be accessed because the related configuration data for the page is invalid
as I read, we can run .NET applications without web config files, but when I tried it is giving me the error. I am using iis 7 on windows 7 machine.
When I create the application virtual directory inside inetpub/wwwroot it works fine. Why doesn't the other directory location?
One reason could be the version of .NET framework (on IIS or application pool level) is different from the application one.
Another reason could be if there are modules used in your web.config which the current configuration of IIS doesn't recognize. E.g. URL rewrite or other optional modules, which you have to explicitly enable before using.
This can be a reason:
If there is no Web.config file in the
UNC directory, IIS 7.0 uses the rules
that are defined for the parent
directory. For the Web content to be
served in this scenario, the
worker-process identity must have
access to the whole content directory.
Otherwise, the Web request is
rejected.
Details here.
You need to set permission for your Website folder or copy them to wwwroot folder.
If you choose to set permission, there are two ways:
Right click on Your Website folder, or
Right click to Your Website in IIS
Then select Edit permission and Add a permission (IUSR - default iis user)

IIS7 Creating Virtual Directory to files on another server

I am migrating some ASP.Net applications from IIS6 to IIS7 and all has gone well until now. I am trying to create several virtual directories on 1 server that will point to files on another server. In IIS6, all I had to do was make anonymous authentication use a user that had access to the files. In IIS7, I can't get it to work. I setup the virtual directory with the username and password but I get a 500.19 error "Cannot read configuration file due to insufficient permissions". I can't imagine that I really have to put a web.config in a directory that just contains images and no application files. If I click on the directory in IIS Manager, I get that error about the web.config file on anything that I click on such as the Authentication section. Also, writing to files from the virtual directory seems to work just fine so I don't think there is anyway that I have an access problem. I have given the directory access to the IIS_IUSR group.
When using a virtual directory that's pointed to a UNC share, go to advanced settings for the virtual directory, then choose a specific user account that has the appropriate rights to access the folder.
It works for my virtual directory in my asp.net app that is pointed to a UNC share on a remote server.

Resources