報錯解決方案" type="hidden"/>

報錯解決方案


在 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了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM