Archive: December 2010

Fixing the ASP.NET “CS0016: Could not write to output file” Error

Scott Walker · Dec 22, 2010

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 = TMP

ADD 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.

đŸ’Ŧ 0

Loading Blog Categories in an MVC View

Scott Walker · Dec 21, 2010

PROBLEM:

To be able to get all Blog data and Categories data into a view, both of which are stored in a database.

SOLUTION:

Add a Categories method to the Blog model which will pull all Categories associated with the Blog.

I added the below code to my Blog Model.

đŸ’Ŧ 0 MVC