Glenn's Blog

Glenn's Blog

My Ramblingsrss


ASP.NET 4.0 and IIS 6.0 Target Framework Error

 
I teach an ASP.NET class and used an old server running Windows 2003 and II6 to allow the students to have their own web page. Everything was fine  until we switched to the .NET Framework 4.0. At this point everyone received the following errors:

Temporary Solution

The temporary solution was to have the students remove the targetFramework directive from their web.config files:

This was definitely a temporary solution because it is difficult to ask beginning students to modify their web.config file without introducing a bunch of errors.

The solution

I searched all over the Internet and found several things that need to be done to get rid of this error. The first was to make sure the application pool for the site was using the .NET framework 4.0. To check this start IIS, right click on your web site, and select properties. Once the properties window opens you want to navigate to the ASP.NET tab. Here you want to make sure the correct version of ASP.NET is selected:


In my case this wasn't a problem, ASP.NET was setup correctly.

Compiler Version in web.config

The next thing to check is to make sure that the compiler version specified in the web.config file is correct. There is a section called compilers and it will specify which compiler the site is using:



Simply change this value to 4.0

Check Root Folder

In my case the web.config file did not define a compilers section. I was totally stumped until one day it dawned on me that I should take a look in the root folder of the site. Sure enough there was a web.config file that had the compiler version wrong. I changed the value from 3.5 to 4.0 and everything works like a charm.


Comments are closed.
Showing 0 Comment