Access is NOT Denied!

Master some useful — and not very obvious — techniques for handling the dreaded “Access is Denied” error.

Don Kiely

October 30, 2009

5 Min Read
ITPro Today logo

Troubleshooting Tips and Tricks

LANGUAGES:C# | VB .NET

TECHNOLOGIES: Indexing Service | Debugging

 

Access is NOT Denied!

Master some useful and not very obvious techniquesfor 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 adatabase. Heck, you can get it on almost any kind of page. The problem withthis error message is there are so many reasons for it that affect so manysystem components that have to work together. And the problem on one machine isunlikely to be the problem on another. What s a geek to do?

 

The Access is Denied problem is one of the most commonquestions in the ASP.NET forums in which I participate. In this article, I llpresent a couple of the more useful and less obvious solutions that folkshave found useful. Hopefully one or more of these will solve your problem whenit rears its ugly head. And just in case it doesn t, I ll cover a few morestrategies in the coming weeks.

 

Indexing Service

One of the most useful resources for solving problems isMicrosoft s Knowledge Base (http://support.microsoft.com).Searching for Access is Denied as an exact phrase in ASP.NET recently yieldedfive articles:

 

  • PRB: Access Is Denied. Check the DCOM ConfigurationSettings for the Machine Debug Manager Error Message When You Debug ASP.NETApplications

  • PRB: Unable to Debug Remote ASP.NET Applications

  • BUG: Access Is Denied Error Message When You Try toAccess Indexing Service from ASP.NET with Impersonation Enabled

  • PRB: Access Denied Error When You Make CodeModifications with Index Services Running

  • INFO: Common Errors When You Debug ASP.NET Applicationsin Visual Studio .NET

 

Clearly, there is an issue with Indexing Service, so let sstart with that one.

 

There are two main problems with Indexing Service:searching the service through an ASP.NET page, and the service s interferencewith code compilation. You ll find a solution to the first problem in KBarticle Q323293 (http://support.microsoft.com/default.aspx?scid=kb;en-us;323293).This problem is fairly straightforward, and it appears only if you enableimpersonation and if the ASP.NET process is using the ASPNET account. It s abug, and the only way around it according to the KB article is to turn offimpersonation either for the entire application or individual pages.

 

More interesting is how Indexing Service can causeproblems when you aren t even using it in your application. This is pretty uglybecause there s nothing about the problem that points to the real cause in theexception message you get. Folks on the forums tear their hair out with thistravesty trying to debug COM interop issues, having problems debugging,encountering all manner of code problems all to no avail because they researching in all the wrong places.

 

The problem rears its head with an exception descriptionlike this: An error occurred during the processing of a configuration filerequired to service this request. Please review the specific error detailsbelow and modify your configuration file appropriately. The problem here isthat the error text implies something is amiss with machine.config or maybeweb.config, sending you off on voyages of discovery that yield no usefulresults.

 

What s happening is when you compile your project, .NETcreates a copy in the temporary ASP.NET files folder, located atC:WINDOWSMicrosoft.NETFrameworkv1.0.3705Temporary ASP.NET Files on mysystem. The files change, so Indexing Service indexes them, causing a lock onthe files potentially for several minutes. This prevents .NET from readingthe files, fooling it into thinking something is wrong with the config files.

 

The best option is to turn off Indexing Service if you renot using it it s just taking up resources and processing cycles. If you douse it, you can specify that the temporary files directory is not to beindexed. 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 deniedis when you debug or run a project. Usually, this really is the error becauseyou need to have some rather exacting permission settings in place to allow allthe ASP.NET magic to happen.

 

If you re debugging an application on your localdevelopment machine, you might get this message: Unable to start debugging onthe web server. Access is denied. Would you like to disable future attempts todebug ASP.NET pages for this project? Clicking on Yes almost never is theright thing to do. In this case, you need to make sure you or at least theuser under which VS .NET is running is a member of the Administrators groupas 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 notdeveloping while logged in with Administrative rights. That can hide subtlesecurity and access problems in your app until it is way too expensive to fixthem. 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 setpermissions in DCOM. Yes, despite the hype, COM and DCOM are not dead in thisbrave new .NET world. Even though you don t need to use COM in yourapplications very much, .NET and VS .NET use it behind the scenes. So check KBarticle Q306164: PRB: Access Is Denied. Check the DCOM Configuration Settingsfor the Machine Debug Manager Error Message When You Debug ASP.NETApplications (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 thecoming weeks, including database access, ASP.NET user foibles, and other commonsituations leading to esoteric exception messages.

 

Happy coding!

 

Don Kiely is senior information architect forInformation Insights, a business and technology consultancy in Fairbanks,Alaska. E-mail him at mailto:[email protected].

 

 

 

 

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like