的问题升级到 .NET 4.0 时的配置组

发布于 2024-09-08 17:33:53 字数 3002 浏览 4 评论 0原文

所以我们已经将我们的网站从 3.5 SP1 升级到了.NET 4。

当我们运行该网站时,我们收到内部服务器错误 (500),指出无法读取以下配置组:

<system.web.extensions>
        <scripting>
            <scriptResourceHandler enableCompression="true" enableCaching="true" />
            <webServices>
                <jsonSerialization maxJsonLength="999999" />
            </webServices>
        </scripting>
    </system.web.extensions>

我们注释掉了此部分,网站运行良好(但现在我们遇到了 JSON 问题 -因为上述所需的属性)。

我们已经阅读过有关此问题的帖子,其中大多数都说“您的应用程序池未运行 4.0”。确实如此,所以这不是问题。

我还读过一些帖子,说 IIS 正在以某种方式读取旧的 machine.config 文件。

如您所知,在 .NET 4 中,web.config 的许多部分已移至 machine.config。

因此,我们将此部分放回 web.config 的顶部:

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
                    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>

现在网站似乎可以正常工作。

不过,我还是有点担心这是否是正确的解决方案。

人们有什么想法吗?这是正确的修复吗?

编辑:

3周了,没有答案......该死。 =)

So we've upgraded our site from 3.5 SP1 -> .NET 4.

When we ran the site, we got an Internal Server Error (500), stating the following configuration group could not be read:

<system.web.extensions>
        <scripting>
            <scriptResourceHandler enableCompression="true" enableCaching="true" />
            <webServices>
                <jsonSerialization maxJsonLength="999999" />
            </webServices>
        </scripting>
    </system.web.extensions>

We commented out this section and the website ran fine (but now we are getting problems with JSON - because of the above required property).

We've read threads on this issue, and most of them say "Your application pool is not running 4.0". And it is, so that's not the issue.

I've also read threads saying IIS is somehow reading an old machine.config file.

With .NET 4, as you know a lot of the sections of web.config have been moved to machine.config.

So we put this section back in the top of the web.config:

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
                    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>

And the website now seems to work ok.

Still, im a little concerned if this is the correct solution.

Any ideas people? Is this the correct fix?

EDIT:

3 weeks and no answers...damn. =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

∝单色的世界 2024-09-15 17:33:54

我最近遇到了这个问题,经过一些故障排除后得以解决。希望我所做的也能帮助解决您的问题。
1. 确保您为站点运行的应用程序池正在使用 .NET 4 管道
2. 在记事本中打开 .csproj(或 .vbproj,如果您的项目是 VB 项目)并浏览该文件,并检查是否有任何对 v2.0 Framework 文件的硬编码引用。就我而言,我们有一个“构建后”任务,该任务使用 v2.0 编译器路径,这迫使应用程序仍使用 2.0 运行时。就像下面这样。

<Target Name=”AfterBuild” Condition=”’$(MvcBuildViews)’==’true’”>
<AspNetCompiler Condition=”’$(IsDesktopBuild)’ != ‘false’” VirtualPath=”temp” ToolPath=”$(WINDIR)\Microsoft.NET\Framework\v2.0.50727” PhysicalPath=”$(ProjectDir)\..\$(ProjectName)” />
<AspNetCompiler Condition=”’$(IsDesktopBuild)’ == ‘false’” VirtualPath=”temp” ToolPath=”$(WINDIR)\Microsoft.NET\Framework\v2.0.50727” PhysicalPath=”$(OutDir)\_PublishedWebsites\$(ProjectName)” />

确保将它们更改为 v4.0 或更好地使其可配置。
希望有帮助。

-瓦姆西

I ran into this issue recently and was able to resolve it after some troubleshooting. Hope what I did will help fix your issue too.
1. Make sure the App pool you are running for the site is using .NET 4 pipeline
2. Open your .csproj (or .vbproj if yours is a VB project) in Notepad and walkthrough the file and check if there are any hard coded references to v2.0 Framework files. In my case we had a "After Build" task that was using v2.0 compiler path which forced the app to still use 2.0 runtime. It was like below.

<Target Name=”AfterBuild” Condition=”’$(MvcBuildViews)’==’true’”>
<AspNetCompiler Condition=”’$(IsDesktopBuild)’ != ‘false’” VirtualPath=”temp” ToolPath=”$(WINDIR)\Microsoft.NET\Framework\v2.0.50727” PhysicalPath=”$(ProjectDir)\..\$(ProjectName)” />
<AspNetCompiler Condition=”’$(IsDesktopBuild)’ == ‘false’” VirtualPath=”temp” ToolPath=”$(WINDIR)\Microsoft.NET\Framework\v2.0.50727” PhysicalPath=”$(OutDir)\_PublishedWebsites\$(ProjectName)” />

Make sure to change them to v4.0 or even better make them confiurable.
Hope that helps.

-Vamsi

乄_柒ぐ汐 2024-09-15 17:33:54

还有两个信息可能有帮助,也可能没有帮助。

  1. 与上面的sectionGroup和我的机器sectionGroup的唯一区别是这里的version=3.5.0.0和machine.config中的version=4.0.0.0。
    1.
  2. 事件日志中的错误是“无法加载站点的所有 ISAPI 过滤器...”是否安装了未在 .net 4 中正确注册的 System.Web.Extensions?

我很想对此进行更多测试,但不幸的是我只在生产系统中看到这种行为,而不是在开发系统中。

Two more bits of info that may or may not help.

  1. the only difference from the above sectionGroup and my machine sectionGroup is the version=3.5.0.0 here and version=4.0.0.0 in the machine.config.
    1.
  2. The error in the event log is "Could not load all ISAPI filters for site..." Could there be an install of System.Web.Extensions that is not registered properly with .net 4?

I'd love to test more on this, but unfortunately I only see this behavior in a production system and not a dev system.

楠木可依 2024-09-15 17:33:53

由于我没有答案,而且大量的谷歌搜索也没有得到任何结果,所以我决定坚持原来的修复(将 system.web.extensions 部分添加回 web.config)。

As i've had no answers, and extensive googling resulted in no love either, i've decided to stick my original fix (adding the system.web.extensions section back into the web.config).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文