IIS forgets virtual directory permissions - An error occurred loading a configuration file: Failed to start monitoring changes - asp.net

I have a website with a virtual directory that contains PDFs.
Users access the PDFs by using a URL such as http://myApp.com/PDFs/12345678.pdf, where PDFs is a virtual directory mapped to \\\actualPhysicalServerName\PDFsDirectory\.
This works.
I routinely re-deploy the application. Once the application is redeployed and the website restarted, users can no longer access the virtual directory until IIS is restarted.
Accessing the above URL gives the following error:
An error occurred loading a configuration file: Failed to start monitoring changes to \\\actualPhysicalServerName\PDFsDirectory\web.config because access is denied.
at System.Web.FileChangesMonitor.FindDirectoryMonitor(String dir, Boolean addIfNotFound, Boolean throwOnError)
at System.Web.FileChangesMonitor.StartMonitoringFile(String alias, FileChangeEventHandler callback)
at System.Web.Configuration.WebConfigurationHost.StartMonitoringStreamForChanges(String streamName, StreamChangeCallback callback)
at System.Configuration.BaseConfigurationRecord.MonitorStream(String configKey, String configSource, String streamname)
at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
Restarting the application pool does not help.
I have to restart IIS.
Once IIS is restarted, the virtual directory can be accessed as expected.
Is this expected behavior? Have I set up my virtual directories incorrectly?
I am using IIS 7.5, Windows 7 server, and .NET 4.5.

I solved this problem this way:
Created new pool with "No managed code" and "Classic" settings.
Converted virtual directory to application, connecting with a user account with permissions on the share
Have application use the new pool

For anyone else frustrated with the same issue - while I did not find the crux of the problem, I did figure out that this problem was related to the Identity of the Application Pool that the website was running under.
In my case, the solution was to change the App Pool identity from the ApplicationPoolIdentity Built-in account to a custom account that is an administrator on all of the machines involved.
To do this
Right click on the application pool in IIS, Choose Advanced Properties.
Under ProcessModel->Identity , choose Identity. Choose Custom Account (Built-in account, Application Pool Identity is the default in IIS 7.5)
Switch to using a Custom Domain account, that is an administrator on this machine, as well as the machine where the virtual directory is hosted.
Restart the Application Pool.

I had a Virtual directory pointing to images on UNC share. All was working fine until we updated parent app to .NET 4.5.
We had to convert the VirDir to Virtual Application with 4.0 Integrated Application Pool.

Old topic but I was able to solve it by following these instructions (basically add ASPNET and IUSR to permissions:
In Windows Explorer, browse to the application folder or to the virtual directory that contains the content (for example, c:\inetpub\wwwroot\xx).
Right-click the folder, and then click Properties.
On the Security tab, click Add.
On the "Select Users or Groups" window, click on Advance
Click on Find Now button, you will see List of users
Select ASPNET and IUSR_(machinename) then click OK to close the"Select Users or Groups" window
Allow the following permissions for the ASPNET and IUSR_(machinename) account:
-Read & Execute
-List Folder Content
-Read

Related

Problem with IIS for creating file on Servers Folder

I have an AspNet App (Blazor) running on IIS server.
I would like to create a txt file on the server, but it doesn't work.
I changed the AppPool identity to a domain user accound and the directories in E: have full permissions for this account.
It works in VisualStudio IIS Express, but not in IIS.
Anyone here who can help me? A permission problem`?
C# Code for creating txt file:
File.WriteAllText(#"E:\Publish\Export\Test.txt", "Hello World");
If you want to save to a specific path, use MapPath (or Server.MapPath) to get the physical path corresponding to the application. Because by default the web server (IIS or local development server) will save to its working directory.
Also you need to make sure the account running IIS has read/write permissions to the directory you need to write to. If you're looking for user accounts, go to "Advanced Settings" under Application Pools and check what's set for "Identity".

access denied for asp.net deployed on iis

I Have an asp.net web application that access files on shared folder from remote host,
when the web application is run from vs2008 it retrives the image files and display them.how ever when i deploy the same project in IIS using virtual directory, the application couldn't access the files on the shared folder it says access denied.
is there any persmission setting i needed to add, I have already add the Asp.net and network service to the project files on the phsical path where the virtual path is pointing too.
string pic3 = #"\\M37350\temp\GraphicUserImage.jpg";
FileInfo f = new FileInfo(pic3);
if (f.Exists)
{
Image1.ImageUrl = pic3;
Image1.Visible = true;
}
Thanks.
VS2008 is using your credentials when executing web application. You will need to set up an account (one that has access to the remote folder) in your IIS virtual directory.
you'll need to set the Application Pool's Identity to a domain account (domain\user) with access to this shared folder, the built-in "Network Service" account doesn't have access to a remote shared folder.
To change your App Pool Identity:
you'll need to know which Application Pool your website is using by going to the Website properties "Home Directory" tab (Application Pool is the last item)
Close out the Website properties and under Application Pools in IIS find the corresponding Application Pool, open properties and go to the "Identity" tab to change the user.
Might also check this answer on serverfault.com: Permission for ASP.NET application on web server to access shared folder on another server
And this step by step for setting custom app pool identity ASP.Net and IIS Support Team Blog for Microsoft France
You need to chmod the shared folder so it is readable and writable to you and/or others. Usually the host has an interface for this. As far as I know, the permissions cannot be set from code.

Trying to set up an application in IIS gives me error: Error message 401.2.: Unauthorized: Logon failed due to server configuration

I created a web application by going to IIS right-clicking on Default Web Site and selecting Add Application. Then I give the Alias name, select DefaultAppPool and point it to Physical path.
When I try to browse to http://localhost/mywebapp I get 'Access is denied' with following details:
Error message 401.2.: Unauthorized: Logon failed due to server
configuration. Verify that you have permission to view this directory
or page based on the credentials you supplied and the authentication
methods enabled on the Web server. Contact the Web server's
administrator for additional assistance.
Anonymous Authentication is enabled on the IIS Website.
The web application is ASP.NET MVC5 application.
The web application is running under its default identity: ApplicationPoolIdentity
Here are the settings for DefaultAppPool
Make sure your application is not on a network share or in the windows user (magic) directory. (It can be in the Visual Studio default magic user directory if you follow my instructions below)
If you're on Win7, create a new MVC 3 application, ^F5 to run. Then in solution explorer, right click the project and select properties. In the left pane, select the Web tab. The default is Cassini ( Use Visual Studio Development Server). Select the next radio, Use Local IIS Web server. Now ^F5 and it will launch your app from IIS. You can also find your application in IIS manager and in the right pane, select browse 80. Now that it's working, compare the differences in your two application.
Your approach should also work. You might try creating a new MVC application and use your approach to test on IIS. The most common mistake is creating a vDir, not an application
The error message is pretty good. To set ACLS on the application pool identity, follow the instructions under Securing Resources at http://learn.iis.net/page.aspx/624/application-pool-identities/
Also see Understanding Built-In User and Group Accounts in IIS 7
IF the new MVC app should fail, repeat, but create a Web Forms app.
Make sure IUSR has permission to the directory that webapp is sitting in.
Also, if your application is accessing permissioned resources(File IO, MSMQ...etc), you will have to change the Identity of the app pool or make sure ISUR has permission.
Make sure that the NETWORK SERVICE account (or whatever system account IIS is using) has permissions to the application folder.
To check the system account that's being used, go to the application pool settings, and the system account will be listed under the Identity tab:
EDIT
Make sure that the application is using the correct application pool. Also, if you haven't already specified a default document, that could be your problem. You can test this by including a page name in the URL, e.g. http://localhost/mywebapp/default.aspx

HTTP Error 401.3 - Unauthorized

I am getting this errror in my newly created website in Windows 7 and IIS 7.5. I created an SSL certificate and done binding new website.
HTTP Error 401.3 - Unauthorized
You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.
Earlier when I created the website, I selected 'application user(pass through authentication)' in 'Add Website' dialogue. and when I click "Test Settings ..." button, I get this error message:
The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that \$ has Read access to the physical path. Then test these settings again.
Please suggest solution to this.
Thanks.
I had the same issue, ensured my DefaultAppPool was running under ApplicationPoolIdentity and the DefaultAppPool had permissions to the folder, but some files still didn't load.
Turns out my problem was that the anonymous authentication user was set to someone else instead of ApplicationPoolIdentity
Screenshot
Make sure that application pool of your website and website both are running under the same identity. Then make sure that this identity has required permissions on the virtual directory. I had exact same issue and above two checks fixed it.
IIS 7 also creates "IUSR" as default user to access files via IIS. So make sure user IUSR has read access to files/folders.
How to check if IUSR has read Access? Right Click -> Folder -> Properties -> Security Tab See if IUSR is in Group or user names list, If No.
Click Edit -> Add -> Advanced -> Find Now -> Select IUSR and click OK -->click Apply
The below worked for me. I did not set up an SSL, just a new website within IIS. Upon doing so I was immediately unable to access the website with this error message.
When I created the new website, a new Application Pool was also created. The Identity of this Application Pool was set to ApplicationPoolIdentity. As mentioned by Suhas, the Application Pool of the website and the website itself must be running under the same identity. (I do not know how to check the identity of the website, but the Application Pool's Identity can be checked by going to Application Pools and looking at the Identity column). The default Application Pool name is DefaultAppPool.
I added permissions to the site (right click the site name -> Edit Permissions -> Security -> Edit -> Add), linking the site to the DefaultAppPool object, which in turn gives the site access to the default user and it's settings. (The default user is created when IIS is installed. Read more about this in Microsoft's docs).
I thought this would be all that's needed to obtain access, but this is incorrect. The website's Application Pool must also be set to DefaultAppPool. This can be done by right clicking on the site -> Manage Website -> Advanced Settings -> Change the Application Pool value to DefaultAppPool.

IIS HTTP Error 403.1 - Forbidden: Execute access is denied

I have a ASP.NET 1.1 application running on IIS 6 / Windows Server 2003.
It's our application, but we're trying to specifically replicate a customer's installation so the app folder has been copied entirely from their production server onto our test machine, and then we've created the Virtual Directory and Web Application for IIS manually.
Internet Information Services (IIS) Manager:
Application Pools
Web Sites
Default Web Site
xxxxx (Virtual Directory)
yyyyy (Web Application)
Web Service Extensions
The problem I have is that when we access the app, we get the standard IIS security error message:
The page cannot be displayed
You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.
--------------------------------------------------------------------------------
Please try the following:
•Contact the Web site administrator if you believe this directory should allow execute access.
HTTP Error 403.1 - Forbidden: Execute access is denied.
Internet Information Services (IIS)
Now this is pretty standard, except as far as I can see it's not anything so simple.
I have checked:
IIS user has read access to the directory
IIS user and Network Service users have read/write access to the Temporary ASP.NET Files folder
Virtual directory is set to the correct version of ASP.NET
ASP.NET 1.1 Web Service Extension is allowed
Virtual directory has the correct mappings of file extensions and all verbs to the aspnet 1.1 DLL
Virtual directory properties allow Scripts and Executables to be run
Anonymous access is turned on and the username and password is correct
What am I missing?
When you did create an application on IIS did you check allow script execution ? You need to turn two first choices on in order to execute anything from this application including virtual directory you have made.
Right click on parent application > Home Directory tab > Executive Permissions set to Scripts only...
You might also need to check the "Edit Feature Permissions..." button on the right pane of the Handler Mappings settings for the specific application and enable "Execute". This is what held my co-workers and I for 3 hours with otherwise pretty identical symptoms.

Resources