<compilation debug="true" targetFramework="4.5"> 報錯解決方案

來源:互聯網
上載者:User

標籤:

在 VS2013 下開發的 MVC4 網站,基於 .net 4.5,伺服器是一台 Windows 2008 R2,啟動並執行時候就報錯了

The ‘targetFramework‘ attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, ‘<compilation targetFramework="4.0">‘). 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.

<system.web>        <compilation debug="true" targetFramework="4.5" />    <httpRuntime targetFramework="4.5" /></system.web>

因為2008 R2預設只安裝了.Net 4,升級.Net 4.5再重新註冊到IIS應該可以解決,但伺服器上不能隨便升級,所以我們需要修改一下配置:

<system.web>        <compilation debug="true" />    <httpRuntime targetFramework="4.0" /></system.web>

compilation是編譯設定,在部署環境無須設定 targetFramework,當然 debug 也可以設定成 false

httpRuntime是運行時,我們知道 .Net 4.0 和 .Net 4.5 的運行時版本都是 .Net 4.0,所以改成4.0就OK了

 

<compilation debug="true" targetFramework="4.5"> 報錯解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.