Troubleshooting Tips and Tricks
LANGUAGES: C# | VB .NET
TECHNOLOGIES: Indexing Service | Debugging
Access is NOT Denied!
Master some useful and not very obvious techniques for handling the dreaded Access is Denied error.
By Don Kiely
One of the most frustrating problems with ASP.NET sites for developers and administrators alike is the dreaded Access is Denied error. You can get it on regular pages. You can get it on pages that access a database. Heck, you can get it on almost any kind of page. The problem with this error message is there are so many reasons for it that affect so many system components that have to work together. And the problem on one machine is unlikely to be the problem on another. What s a geek to do?
The Access is Denied problem is one of the most common questions in the ASP.NET forums in which I participate. In this article, I ll present a couple of the more useful and less obvious solutions that folks have found useful. Hopefully one or more of these will solve your problem when it rears its ugly head. And just in case it doesn t, I ll cover a few more strategies in the coming weeks.
One of the most useful resources for solving problems is Microsoft s Knowledge Base (http://support.microsoft.com). Searching for Access is Denied as an exact phrase in ASP.NET recently yielded five articles:
- PRB: Access Is Denied. Check the DCOM Configuration Settings for the Machine Debug Manager Error Message When You Debug ASP.NET Applications
- PRB: Unable to Debug Remote ASP.NET Applications
- BUG: Access Is Denied Error Message When You Try to Access Indexing Service from ASP.NET with Impersonation Enabled
- PRB: Access Denied Error When You Make Code Modifications with Index Services Running
- INFO: Common Errors When You Debug ASP.NET Applications in Visual Studio .NET
Clearly, there is an issue with Indexing Service, so let s start with that one.
There are two main problems with Indexing Service: searching the service through an ASP.NET page, and the service s interference with code compilation. You ll find a solution to the first problem in KB article Q323293 (http://support.microsoft.com/default.aspx?scid=kb;en-us;323293). This problem is fairly straightforward, and it appears only if you enable impersonation and if the ASP.NET process is using the ASPNET account. It s a bug, and the only way around it according to the KB article is to turn off impersonation either for the entire application or individual pages.
More interesting is how Indexing Service can cause problems when you aren t even using it in your application. This is pretty ugly because there s nothing about the problem that points to the real cause in the exception message you get. Folks on the forums tear their hair out with this travesty trying to debug COM interop issues, having problems debugging, encountering all manner of code problems all to no avail because they re searching in all the wrong places.
The problem rears its head with an exception description like this: 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. The problem here is that the error text implies something is amiss with machine.config or maybe web.config, sending you off on voyages of discovery that yield no useful results.
What s happening is when you compile your project, .NET creates a copy in the temporary ASP.NET files folder, located at C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files on my system. The files change, so Indexing Service indexes them, causing a lock on the files potentially for several minutes. This prevents .NET from reading the files, fooling it into thinking something is wrong with the config files.
The best option is to turn off Indexing Service if you re not using it it s just taking up resources and processing cycles. If you do use it, you can specify that the temporary files directory is not to be indexed. See the details in KB article Q329065 (http://support.microsoft.com/default.aspx?scid=kb;en-us;329065).
Debugging and Running Projects
Another common situation where access is allegedly denied is when you debug or run a project. Usually, this really is the error because you need to have some rather exacting permission settings in place to allow all the ASP.NET magic to happen.
If you re debugging an application on your local development machine, you might get this message: Unable to start debugging on the web server. Access is denied. Would you like to disable future attempts to debug ASP.NET pages for this project? Clicking on Yes almost never is the right thing to do. In this case, you need to make sure you or at least the user under which VS .NET is running is a member of the Administrators group as well as the Debugger Users group ASP.NET sets up when you install VS .NET. You need these permissions to debug the ASP.NET worker process (Aspnet_wp.exe).
Alas, this is evil because of the wise practice of not developing while logged in with Administrative rights. That can hide subtle security and access problems in your app until it is way too expensive to fix them. The solution here is probably to log on to one account for debugging, then log on to another for regular development work. Yikes.
If you re debugging a remote machine, you ll have to set permissions in DCOM. Yes, despite the hype, COM and DCOM are not dead in this brave new .NET world. Even though you don t need to use COM in your applications very much, .NET and VS .NET use it behind the scenes. So check KB article Q306164: PRB: Access Is Denied. Check the DCOM Configuration Settings for the Machine Debug Manager Error Message When You Debug ASP.NET Applications (http://support.microsoft.com/default.aspx?scid=kb;en-us;306164) for instructions about how to set up DCOM to debug remotely.
I ll cover a few more Access is Denied problems in the coming weeks, including database access, ASP.NET user foibles, and other common situations leading to esoteric exception messages.
Don Kiely is senior information architect for Information Insights, a business and technology consultancy in Fairbanks, Alaska. E-mail him at mailto:[email protected].