7
votes

I have just uploaded a website to my server. And it works perfectly locally, but after I uploaded, the online version displays this:

Configuration Error    Description: An error occurred during the
processing of a configuration file required to service this request.
Please review the specific error details below and modify your
configuration file appropriately. 

 Parser Error Message: Unrecognized attribute 'targetFramework'. Note
that attribute names are case-sensitive.

Source Error: 



Line 37:     </buildProviders>
Line 38:     </compilation>
Line 39:     <httpRuntime targetFramework="4.0"
encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Line 40:     <machineKey compatibilityMode="Framework45" />
Line 41:  </system.web>


 Source File:  D:\HostingSpaces\o\o.com.au\wwwroot\web.config    Line:
39 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.272

According to other answers on this site, its because the account on the server is set to use .NET Framework 2.0. BUT that's not the case with mine, I've made sure that it's set to 4.0 and I've even tried 4.0 Integrated. But it still displays this error.

What could be causing this? How can I fix it?

enter image description here

4
The other answers are correct, the runtime is set to the wrong version.asawyer
Hmm I don't have a win 7 IIS panel to look at in front of me... Certainly does look correct though. Could try reregistering asp.net with aspnet_regiis.exe -iasawyer
This is strange. This error is almost always because the .NET version is not 4. Though the bottom of your error message indicates that you already are on 4. You may need to get your hosting provider involved in this.vcsjones
Check if your local and server has the same version of .net 4.0 . I see that you server has 4.0.30319 but is your local the exact same version ??Antony Thomas
compatibilityMode="Framework45" is interesting. Did you develop an ASP.NET 4.5 website?vcsjones

4 Answers

18
votes

The application is trying to use features that are new to ASP.NET 4.5 (see in particular the <httpRuntime> and <machineKey> elements), but the server only has ASP.NET 4.0. Remove the <httpRuntime> and <machineKey> elements from Web.config to solve the issue.

(Fun fact: the <httpRuntime/targetFramework> attribute didn't exist until 4.5. So even though the value says "4.0," the server still fails since it's not expecting to see this attribute at all.)

9
votes

This issue can be fixed by going to IIS, click Application Pools and set Version to 4.0 (Integrated)(the one that is running the site). The accepted answer says HttpRunTime/targetFrameWork> does not exists until in 4.5. This is incorrect. For reference, this is HttpRuntime V2 Doc. TargetFrameWork is new to Version 4.

The problem in the OP question is, he set the .NET version of the site to 4 but on remote server, 2.0 was running hence the error. In that case since he has no control over remote server (assuming), changing .NET version to 2.0 locally would fix the problem, without fiddling with web.config.

3
votes

i think you application pool in IIS is not setup correctly, you must set your apllication pool to ASP.NET v4.0.

hope this help

0
votes

In my case this the solution wasn't to do with not having ASP.NET 4 on my servers. My servers are on a load-balancer and the files for the website are on a Distributed File System. I needed to connect to the DFS with a valid user and password. When this was done I no longer saw the error. However, if you are experiencing this problem check the other solutions first. I would say if you see this error, then nine times out of ten it will be the case that the NET Framework is either not on the server, or not specified for the App Pool.