Fixing the ASP.NET “CS0016: Could not write to output file” Error
Just finished creating my new ASP.NET 4 application and after I copy over the files from my development server to production, I get the dreaded "CS0016: Could not write to output file" error!
This is usually an indication that their is a permission problem of some sort. After searching for a while on google, I decided to do some of my own tests. From looking on the web, people were having success adding NETWORK SERVICE and the IIS_IUSRS accounts to the folder below:
%SYSTEMROOT%\TEMP1 = TEMP%SYSTEMROOT%\TEMP1 = TMP
Above is actually Microsoft's recommendation as well. I began to do tests, by removing my application completely and adding just a default.aspx page and a default web.config file. Then the error was more specific and indicated that C:WINDOWS\TEMP was not there. So, my solution was to create the folder and add both user accounts to the folder which allowed my application to run.
C:\WINDOWS\TEMP = TEMP C:\WINDOWS\TEMP = TMPADD THESE ACCOUNTS: NETWORK SERVICE and IIS_IUSRS
This hopefully will sove any permission problems. ASP.NET uses the temp folders before writing data to the Framework folders.