Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration Error related to targetFramework in web.config

I have made an MVC website in Visual Studio 2015 and it works in my localhost. But when I published my website and put into my host, it doesn't work. It gives me this error notice:

Server Error in '/' Application.

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

Source Error:

An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Source File: G:\xxx\xxx.com\httpdocs\web.config Line: 24

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248

Related parts in my web.config:

  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>

And this part with error:

  <system.web>
    <authentication mode="None" />
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.6" />
    <httpRuntime targetFramework="4.6" />
  </system.web>

Properties of my website:

enter image description here

And NuGet Package Manager:

enter image description here

EntityFramework Reference Properties:

enter image description here

Default Web Site Basic Settings: (To be honest, I am not sure whether I should add a new website(my website) in here.)

enter image description here

My installed .net frameworks:

enter image description here

My publish method:

enter image description here

I have investigated this problem on the Internet and I have found several links related to my problem: Asp.net MCV4 framework issue. In this link, there are two main offers:

  1. changing this compilation tag

  2. updating application pool in IIS

Actually, I have tried to change this tag but it doesn't change. Then I have controlled my application pool but it seems up-to-date.

enter image description here

I have called my host provider and I have explained my problem. They say that this error is not related to their servers.

What should I do? What is the solution for this?

like image 971
rockenpeace Avatar asked Oct 29 '15 10:10

rockenpeace


People also ask

What is targetFramework in web config?

The reason of targetFramework existence in web. config is to keep compatibility issues out between breaking changes for each version of . NET Framework. The difference between targetFramework on compilation and httpRuntime belongs to each development and deployment environment.

What is targetFramework?

When you target a framework in an app or library, you're specifying the set of APIs that you'd like to make available to the app or library. You specify the target framework in your project file using a target framework moniker (TFM). An app or library can target a version of .


3 Answers

Your website project is targeting v4.6 of the .Net Framework but your hosting provider has not yet installed this version. Your options:

  1. Ask provider to install it - they are unlikely to do this.
  2. Find another provider that does support it.
  3. Change your project to target v4.5.
like image 154
DavidG Avatar answered Oct 03 '22 23:10

DavidG


@DavidG has rightly pointed all the things. Just on informational side if IIS is your provider then Web Platform Installer is your best bet to check the current state of what all is installed on your machine currently. Have a look at the below snapshot -

enter image description here

It is really handy to check what all is missing and you can kick-start installation of all the missing pieces in one click.

like image 23
RBT Avatar answered Oct 04 '22 00:10

RBT


I just had a similar problem following the installation ( windows update) of the KB 3205402.

Big difference with my case: the application worked well before the update !

==> I found in "IIS Manager", in "ISAPI and CGI Restrictions", that the framework ASP.NET v4.0.30319 has been switched to "unauthorized" !

Switching it to "Authorized" resolved my problem

like image 27
Didier68 Avatar answered Oct 04 '22 00:10

Didier68