Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 739
dedgod Avatar asked Jun 17 '13 17:06

dedgod


3 Answers

I solved this problem this way:

  1. Created new pool with "No managed code" and "Classic" settings.
  2. Converted virtual directory to application, connecting with a user account with permissions on the share
  3. Have application use the new pool
like image 200
mabian69 Avatar answered Nov 16 '22 03:11

mabian69


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.
like image 23
dedgod Avatar answered Nov 16 '22 03:11

dedgod


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.

like image 40
gbs Avatar answered Nov 16 '22 03:11

gbs