Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC 5 web.config <system.web> compilation & httpRuntime error

When I deploy my mvc application to my IIS 7 server it has the following in the web.config file:

  <system.web>
    <compilation targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
  </system.web>

Having the compilation & httpRuntime tags in give me the following error:

Parser Error Message: The 'targetFramework' attribute in the element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, ''). The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework.

So just for giggles I removed the compilation & httpRuntime tags and then the sites works perfectly! The server has 4.5.1 on it. I'm guessing this is something about the application pool, but it looks like the only options in the application pool are: No Managed Code, .NET Framework v2.0, .Net Framework v4.0. There isn't an option for v4.5 or v4.5.1. Right now it's set to v4.0.

I didn't really understand what compilation and httpRuntime are used for and why they are even in my web.config as I didn't explicitly place them there.

like image 294
user441521 Avatar asked May 13 '14 14:05

user441521


2 Answers

There are two ways Microsoft updates .NET Framework:

  • Side by Side Release, just like v1.1, 2.0, 4
  • Enhancement, just like 3, 3.5, 4.5

That means when you install .NET 4.5 the v4.0 folder is just updated to contain the .NET 4.5 files.

IIS only shows the Side by Side releases , not the enhancements. Since 4.5 is an enhancement, it is applied to the framework folder of v4.0. Thats also explains why you only see .NET Framework v2.0 and .Net Framework v4.0 as options under IIS application pool.

As for the targetFramework attribute, its is only recognized for framework 4.0, not prior.

The targetFramework attribute has two effects:

  • It controls the Common Language Runtime's quirks mode behavior
  • It works as a shortcut that allows the ASP.NET runtime to infer a wide array of configuration settings

Removing the attributes did solve your issue, but it is not the healthiest thing to do. I think you should check the server's registry for which framework updates are installed on the server, check if the website is also configured to work for framework 4.

like image 198
stripthesoul Avatar answered Sep 23 '22 22:09

stripthesoul


You just need to upgrade your .NET framework to ver 4.5 in your IIS 7.5 server you do that using the Microsoft web installer software on the server do a search for .NET and then installed the .NET framework version 4.5 and the all the apps that target that version will work

like image 22
Cesar Vega Avatar answered Sep 23 '22 22:09

Cesar Vega