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

dedgod picture dedgod · Jun 17, 2013 · Viewed 32.7k times · Source

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.

Answer

mabian69 picture mabian69 · Nov 5, 2013

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