When trying to run an ASP.NET application, you might see a CS0016 error with a message like the following:
CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\...App_GlobalResources.***.dll'--'Access is denied.'
This error occurs because of a permissions problem on the Temporary ASP.NET Files directory. This directory should allow the ASP.NET service account–typically the NETWORK SERVICE account–to generate temporary DLLs used by the just-in-time compilation system in ASP.NET. In this case, though, something is wrong.
There are three approaches to address the problem. Since this error should really not occur in a properly-installed ASP.NET installation, you should first try to re-register ASP.NET. Follow the article at http://webactivedirectory.com/knowledge-base/fix-http-error-403-14-forbidden-errors/ and choose the appropriate version of ASP.NET and 32- or 64-bit for your system. This will re-register the .NET framework and force a restart of IIS.
The second approach concerns the Temp directory used by Windows. If you see a message like “The directory name is invalid.” you should set the Windows system’s Temp directory using the guidance at https://support.microsoft.com/en-us/kb/825791. Make sure to look up what Temp directory the system is using according to the instructions in the article. You can grant either the NETWORK SERVICE account or the IIS_IUSRS group (or whichever account or group is running the ASP.NET web application) Modify permissions on the C:\Windows\Temp directory.
The third approach adjusts the permissions directly on the Temp directory itself. You can assign NETWORK SERVICE (or whatever service account your web application is using in ASP.NET) the following permissions on C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files. You should restart IIS after performing the change.
•Read & Execute
•List Folder Contents
You can use the FileMon tool from https://technet.microsoft.com/en-us/sysinternals/bb896642.aspx to get an exact picture of which directories are causing permissions problems.
Check out some other resources below if you need further options and information about this type of permissions error in ASP.NET.
•How do I fix the “Unable to generate a temporary class” error? http://webactivedirectory.com/knowledge-base/fix-unable-generate-temporary-class-error/
•Why do I receive the following error message? System.InvalidOperationException: Unable to generate a temporary class (result=1): http://webactivedirectory.com/knowledge-base/system-invalidoperationexception-unable-generate-temporary-class-result1/
•How do I fix HTTP Error 403.14 – Forbidden errors? http://webactivedirectory.com/knowledge-base/fix-http-error-403-14-forbidden-errors/