简体   繁体   English

在 .NET Framework 4 中运行基于 .NET Framework 3.5 的应用程序时出现 HTTP 错误 500.19 - 内部服务器错误

[英]running a .NET Framework 3.5-based application in .NET Framework 4 getting HTTP Error 500.19 - Internal Server Error

I have assigned a task to debug some issue for a previously build project.我分配了一个任务来调试以前构建项目的一些问题。 When I am running the project in Visual Studio 13 I got below --当我在 Visual Studio 13 中运行项目时,我得到了以下信息——

在此处输入图片说明

Emphasis on this line--强调这一行——

this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4此错误是因为您在 .NET Framework 4 中运行基于 .NET Framework 3.5 的应用程序

I go through this articles--我浏览了这篇文章——

.net 3.5 application on .net 4.0 runtime .net 4.0 运行时上的 .net 3.5 应用程序

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/version-compatibility https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/version-compatibility

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-configure-an-app-to-support-net-framework-4-or-4-5 https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-configure-an-app-to-support-net-framework-4-or-4-5

Problem with .Net Framework 3.5 applications running in .Net Framework 4 在 .Net Framework 4 中运行的 .Net Framework 3.5 应用程序的问题

I placed below code in my webconfig configuration section --我把下面的代码放在我的 webconfig 配置部分——

<startup>
    <supportedRuntime version="v4.0" /> 
    <supportedRuntime version="v2.0.50727" /> 
</startup>

But nothing changed.但什么都没有改变。 According to this article --根据这篇文章——

https://docs.microsoft.com/en-us/dotnet/framework/install/dotnet-35-windows-10 https://docs.microsoft.com/en-us/dotnet/framework/install/dotnet-35-windows-10

I enabled .net framework 3.5 in control panel.我在控制面板中启用了 .net framework 3.5。 Still no hope with the same error.仍然没有希望出现同样的错误。 Can anyone suggest me how can I get rid of this error or start the project without any problem?谁能建议我如何摆脱此错误或毫无问题地启动项目?

My Web Config is as below:我的网络配置如下:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>

  <connectionStrings>
  <!--conectionstring is here-->
  </connectionStrings>
  <startup>  
    <supportedRuntime version="v4.0"/>
    <supportedRuntime version="v2.0.50727"/>
   </startup>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="PreserveLoginUrl" value="true"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <!--
    For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <!--<httpRuntime executionTimeout="5000"/>-->
    <httpRuntime maxRequestLength="12288"/>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
    <authentication mode="None"/>
    <pages controlRenderingCompatibilityVersion="4.0">
      <namespaces>
        <add namespace="System.Web.Helpers"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
      </providers>
    </roleManager>
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection"/>
      </providers>
    </sessionState>
  </system.web>
  <system.webServer>
  <!-- For ModSecurity-->
   <validation validateIntegratedModeConfiguration="false"/>
   <ModSecurity enabled="false" configFile="C:\inetpub\wwwroot\owasp_crs\modsecurity.conf"/>
    <!-- For Videos
    <staticContent>
      <mimeMap fileExtension=".mp4" mimeType="video/mp4"/>
      <mimeMap fileExtension=".m4v" mimeType="video/m4v"/>
    </staticContent>-->
    <!--<validation validateIntegratedModeConfiguration="false" />-->
    <modules runAllManagedModulesForAllRequests="true"/>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
            </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
  </entityFramework>
</configuration>

After monitoring the web.config file contents, it was found that following line of configuration was causing the error:在监控 web.config 文件内容后,发现以下配置行导致错误:

<ModSecurity enabled="false" configFile="C:\inetpub\wwwroot\owasp_crs\modsecurity.conf"/>

After commenting out that line of code, the error was fixed.注释掉那行代码后,错误就修复了。

The error message states that the configuration data is invalid which might have to do with updates to .NET 4.0 as stated on .NET Framework 4 migration issues section of the Migration Guide to the .NET Framework 4.7, 4.6, and 4.5 :错误消息指出配置数据无效,这可能与.NET Framework 4.0 的更新有关,如.NET Framework 4.7、4.6 和 4.5 迁移指南的.NET Framework 4 迁移问题部分所述:

Configuration files The root configuration files (the machine.config file and the root Web.config file) for the .NET Framework and ASP.NET 4 have been updated to include most of the boilerplate configuration information that was found in the application Web.config files in ASP.NET 3.5.配置文件 .NET Framework 和 ASP.NET 4 的根配置文件(machine.config 文件和根 Web.config 文件)已更新,以包含在应用程序 Web.config 中找到的大部分样板配置信息ASP.NET 3.5 中的文件。 Because of the complexity of the managed IIS 7 and IIS 7.5 configuration systems, running ASP.NET 3.5 applications under ASP.NET 4 and under IIS 7 and IIS 7.5 can result in either ASP.NET errors or IIS errors.由于托管 IIS 7 和 IIS 7.5 配置系统的复杂性,在 ASP.NET 4 和 IIS 7 和 IIS 7.5 下运行 ASP.NET 3.5 应用程序可能会导致 ASP.NET 错误或 IIS 错误。 Upgrade ASP.NET 3.5 applications to ASP.NET 4 by using the project upgrade tools in Visual Studio 2010. Visual Studio 2010 automatically modifies the ASP.NET 3.5 application's Web.config file to contain the appropriate settings for ASP.NET 4.使用 Visual Studio 2010 中的项目升级工具将 ASP.NET 3.5 应用程序升级到 ASP.NET 4。Visual Studio 2010 会自动修改 ASP.NET 3.5 应用程序的 Web.config 文件以包含适用于 ASP.NET 4 的设置。

However, you can run ASP.NET 3.5 applications using the .NET Framework 4 without recompilation.但是,您可以使用 .NET Framework 4 运行 ASP.NET 3.5 应用程序,而无需重新编译。 In that case, you might have to manually modify the application's Web.config file before you run the application under the .NET Framework 4 and under IIS 7 or IIS 7.5.在这种情况下,在 .NET Framework 4 和 IIS 7 或 IIS 7.5 下运行应用程序之前,您可能必须手动修改应用程序的 Web.config 文件。 The specific change you must make depends on the combination of software you are working with, including Service Pack (SP) releases.您必须进行的具体更改取决于您使用的软件组合,包括 Service Pack (SP) 版本。 For information about the possible software combinations that are affected by this change and how to resolve problems with specific combinations, see the section "Configuration Errors Related to New ASP.NET 4 Root Configuration" in the document ASP.NET 4 Breaking Changes on the ASP.NET Web site.有关受此更改影响的可能软件组合以及如何解决特定组合问题的信息,请参阅文档ASP.NET 4 Breaking Changes on the ASP 中的“与新 ASP.NET 4 根配置相关的配置错误”部分.NET 网站。

ASP.NET 4 Breaking Changes states two sources of errors: ASP.NET 4 Breaking Changes指出了两个错误来源:

  1. incorrect merger of machine.config and Web.config machine.config 和 Web.config 的错误合并
  2. configuration comparison fails due to version numbers not matching由于版本号不匹配,配置比较失败

Another option might be to change the order of the framework specification as it will use them in the preferred order from top to bottom as stated in Version Compatibility in the .NET Framework :另一种选择可能是更改框架规范的顺序,因为它将按照从上到下的首选顺序使用它们,如.NET Framework中的版本兼容性中所述

So perhaps this will work as well:所以也许这也会起作用:

<startup>
    <supportedRuntime version="v2.0.50727" /> 
    <supportedRuntime version="v4.0" /> 
</startup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HTTP错误500.19-升级到.net 4.5框架时出现内部服务器错误 - HTTP Error 500.19 - Internal Server Error on upgrading to .net 4.5 framework HTTP错误500.19,Windows 7上带有框架3.5的网站 - HTTP Error 500.19 , website with framework 3.5 on windows 7 HTTP错误500.19-BlogEngine.NET中的内部服务器错误 - HTTP Error 500.19 - Internal Server Error in BlogEngine.NET 当在 IIS 中发布 .net 核心 web 应用程序的示例项目时,出现 Z293C9EA246FF99875DC6F62A5601 内部服务器错误。 - When Publish sample project of .net core web app in IIS getting HTTP Error 500.19 Internal Server Error 获取内部服务器错误500.19 - Getting internal server error 500.19 HTTP错误500.19 - ReportViewerWebControlHandler上的内部服务器错误 - HTTP Error 500.19 - Internal Server Error on ReportViewerWebControlHandler HTTP错误500.19-内部服务器错误localhost - HTTP Error 500.19 - Internal Server Error localhost HTTP错误500.19内部服务器错误 - HTTP Error 500.19 Internal Server Error Windows 8和Windows Server 2012抛出错误“.Net Framework 3.5未安装” - Windows 8 and Windows server 2012 are throwing an error “.Net Framework 3.5 is not installed” 迁移winform .net framework 3.5到4时出错 - Error migrating winform .net framework 3.5 to 4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM