CS0016 Error on ASP.NET, IIS7 and Windows Vista - SOLVED
So, I was messing with some ideas for site structure and security, and it came to my deploying the site to IIS.
Now, I admit, I am still pretty new to IIS7 and Windows Vista (Home Premium), so I was expecting some issues, but this was kicked my ass for a good 45 mins!
Once I had deployed my site and browsed to it, I was getting the following error:
CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\… ‘Access is denied.’
(Where … is the randomly-generated DLL names created by ASP.NET).
So, I figured, “OK this is probably a permissions issue” as I have encountered similar before in XP, where the ASPNET user account needed to be added. I also know that in Vista this account is called “NETWORK SERVICE”. I then update the permissions for the “Temporary ASP.NET Files” folder in the .NET Framework folder, eagerly get back to my browser, hit F5.. Boom. No dice, same error message.
After doing some digging on the Internet I found out that you also need to set the permissions for the C:\Windows\Temp folder!
To resolve, ensure your permissions are correct for both temp directories:
- Browse to “C:\Windows\Microsoft.NET\Framework\{Vers.}\”.
- Right click the “Temporary ASP.NET Files” folder.
- Click “Properties”.
- Click the “Security” tab.
- Click “Edit” and confirm the UAC prompt.
- Click the “Add” button.
- In the “Enter Object Name” field, enter “NETWORK SERVICE”.
- Click “Check Names”, it should become underlined to confirm it is OK.
- Click OK.
- With the “NETWORK SERVICE” user selected, in the "Permissions for..” list, check the “Full Control – Allow” check box.
- Click “Apply” and “Yes” to the security prompt.
- Finally click “OK” to close the properties dialog.
- Repeat the above steps on the “C:\Windows\Temp” folder as well! (i.e. browse to “C:\Windows”, right click “Temp”, click “Properties” etc. etc.).
To be honest, I wasn’t sure I believed it at first. But I deleted all temp files from both folders and reset/removed the permissions, and the error reared its ugly head again.
I hope this helps any others with the same problem save time!
You are win. I read a hell of alot of explanations but yours was the first to recommend this. I had changed my environment vars to c:\temp\ but strangely I still had to set NETWORK SERVICE to full permissions on c:\windows\temp\ like you said (in addition to the .net temp dir), at least now I can get to work ; )
ReplyDeleteAnon,
ReplyDeleteReally glad it helped, I know how frustrating it is!
The only answer that worked! Thank you very much.
ReplyDeleteThank YOU!
ReplyDeleteHey, Thanks A LOT!!!!, I've been trying to work around with this problem for hours! and finally found the answer with your post. Again, Thanks a Lot!
ReplyDeleteYou sir are a Legend :-)
ReplyDeleteMr. Geek,
ReplyDeleteI say Mr. Geek out of pure respect, because I am so tired of the millions of times that I go to a site looking for help on an issue like this one and get told to do things that have no bearing on the problem. I follow the instructions - if there is a clear place to start - often without success. You made this solution even better by showing that you went through the same efforts before you solved it. Thanks.
Thanks for taking the time out to submit the great feedback, really pleased this post has helped so many :)
ReplyDeleteWow. I've been pulling my hair out for the last couple of hours on this problem. Sure enough: giving NETWORK SERVICE access to \Windows\Temp fixed it. Thanks!
ReplyDeleteJust to let you know how much I appreciated this post! This thing was driving me nuts. Thanks!:)
ReplyDeleteHi! Thanks a lot for posting this solution, it's the only one I found that could fix this problem! Many thanks! :)
ReplyDeleteDavid from Perú.
ReplyDeleteThanks Rob! We are ending 2011 and your advise is still valuable. Let me say this solution is valid for any application that uses .Net Framework and shows the same problem.