IIS的配置问题:Server Error in '/' Application.

来源:互联网 发布:mac好用的邮箱软件 编辑:程序博客网 时间:2024/06/03 01:53

配置完IIS后打开网站,出现错误:

Server Error in '/' Application.--------------------------------------------------------------------------------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: 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.

导致这种错误的原因就是IIS使用的framework版本不正确。项目框架使用framework 4.5,而服务器中没有安装framework 4.5造成的。

一般的解决方法:
1. 把项目框架改完4.0,编译后重新发布,但是当项目比较打的时候并不适用,改变项目框架会导致很多不可控的问题。
2. 配置IIS应用程序池framework版本为4.5
但其实IIS中是找不到framework为4.5版本的。
这里写图片描述

stackoverflow上解释:

When .NET 4.5 is installed it effectively replaces .NET 4.0 on the machine. .NET 4.0 gets overwritten by a new version of .NET 4.5 which - according to Microsoft - is supposed to be 100% backwards compatible. 大致意思就是:4.5本质上还是4.0,属于递增式的更新,所以对IIS 来说看到的只有4.0而已。所以即便安装了4.5,还是只能选择4.0.

所以出现这种情况的时候就需要考虑服务器上是否已经安装了framework 4.5了.

0 0
原创粉丝点击