Search code examples
asp.netvisual-studio-2010web-configaccess-denied

Visual Studio 2010 + ASP.Net Web Project: Looking in current folder for web.config (instead of root)


So I have been developing this application for my boss over the past few weeks and then last night the IT Administrator jacks with my machine. I think the only thing he did was rename the computer name, but there could be more. Anyway, I reopen the project after getting on the computer and now the ASP.Net web project is looking into the current directory of every aspx file for a web.config instead of for the web.config in the root of the project directory (where it has been this whole time).

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred loading a configuration file: Failed to start monitoring changes to 'C:\*web project location*\pages' because access is denied.

Source Error:

[No relevant source lines]

Source File: C:\*web project location*\pages\web.config

The web.config file is located and should load under c:\*web project location*\web.config. There is no other web.config files in the project. I have various folders defined in the project for different parts of the application, a folder for UserControls and for MasterPages. If I open any aspx file from one of these sub folders, the <%@ Page %> directive says it is looking for a web.config file in that directory instead of the root of the project.

Please help! I have been Googling and searching stack for an answer with no results. The only details I can find related to this occurring when deploying to IIS. I am not doing that.

Thank you in advance for your help. It is much appreciated.


Solution

  • I found the answer to this question. The Web Project was impersonating an identity.

    From my web.config:

    <authentication mode="Windows" />
    <identity impersonate="true" userName="DOMAIN\AppUser" password="Password" />
    

    Not sure why the issue started occurring after the machine name was changed, but I was able to resolve the problem by adding the impersonating identity to the workstation (Win7) under Control Panel > Users > Manage Users and also by adding full permissions to the project directory for that identity.

    I also found this post which led me to an even better possible option:

    http://bytes.com/topic/asp-net/answers/309339-failed-start-monitoring-file-changes

    http://support.microsoft.com/default.aspx?scid=kb;en-us;824308

    Changing the Security Policy of the workstation should prevent future problems if other identities were used. I did not try this option yet however, because I have a deadline to meet.