尝试将一个 .net 3.5 网站部署到 IIS7 的默认应用程序池中,当设置 framework 属性为4.0 时,会出现以下错误:
有一个重复的 'system.web.extensions/scripting/scriptResourceHandler' 部分被定义。
注释掉有问题的行也没有帮助。请问我需要做什么或查看哪些方面?
尝试将一个 .net 3.5 网站部署到 IIS7 的默认应用程序池中,当设置 framework 属性为4.0 时,会出现以下错误:
有一个重复的 'system.web.extensions/scripting/scriptResourceHandler' 部分被定义。
注释掉有问题的行也没有帮助。请问我需要做什么或查看哪些方面?
另一个快速解决方法是将应用程序池设置为2.0,就像您的开发机器一样。
如果像我一样,您需要针对v4进行目标定位,但只能使用.net 3.5进行构建,请按照此处的说明操作。只需用以下内容替换web.config中<configSections>
的全部内容:
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
:一个空段落。将应用程序池设置为2.0,我做了并且有效。
死灵法术。
如果你的web.config中没有system.web.extensions配置部分或处理程序/模块条目,则这个问题是由于你/其他人复制了一个VisualStudio项目(2013/2015/2017),同时取消隐藏了隐藏文件导致的。
因此,它不仅会复制.git,还会复制.VS文件夹,其中包含一个IIS-Expressapplicationhost.config文件,它指向不存在的路径下的web.config文件(或更糟糕的是指向存在但内容不同的路径)...
解决方案:
删除.VS文件夹中的applicationhost.config文件。
或者干脆删除整个.VS文件夹。
Visual Studio将重新创建它。
<rules>
标签): <rewrite>
<rule name="some rule" stopProcessing="true">
<match url="some-pattenr/(.*)" />
<action type="Redirect" url="/some-ne-pattenr/{R:1}" />
</rule>
</rewrite>
</system.webServer>
</configuration>
正确的代码(带有规则标签):
<rewrite>
<rules>
<rule name="some rule" stopProcessing="true">
<match url="some-pattenr/(.*)" />
<action type="Redirect" url="/some-ne-pattenr/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
这个错误信息似乎在各种情况下都会出现。
在我的情况下,在我的应用程序的 Web.Config 文件之上,我在根文件夹(C:\Inetpub\www.root)中有一个额外的 Web.Config 文件。可能是在一些测试后留下来的,我已经忘记了所有关于它的事情,并且无法弄清楚问题所在。
将其删除解决了我的问题。