Solution for ASP.NET access to temporary folder denied error

By , August 24, 2011 12:11 pm

Scenario: You’re trying to run an ASP.NET application when suddenly an error is thrown similar to this:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0016: Could not write to output file ‘c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\……..\………\some_code.dll’ — ‘Access is denied. ‘

You gave that folder all possible permissions imaginable and still the error persist. What the?

Well, as old saying goes – if you see “Tiger” written on the cage of an elephant – do not beleive your eyes. Even though .NET points you to “Temporary ASP.NET Files” folder in reality it means system temp folder. You can locate it by typing SET command in DOS command prompt or looking in Advanced Setting of your server Computer Properties, System Environmental Variables, for example:

Temp folder in environmental variables

Give ASP.NET account (ASPNET or NETWORK SERVICE, depends on your system) read/write access to *that* folder and run your app happily ever after.

Leave a Reply

Panorama Theme by Themocracy