简体   繁体   English

.net核心应用程序错误502.5如果在IIS中作为虚拟目录运行

[英].net core application error 502.5 if run as virtual directory in IIS

I am having problem configuring .net core application to work as virtual directory in iis. 我在配置.net核心应用程序以在iis中作为虚拟目录工作时遇到问题。 If i start .net core application directly with its port it works fine. 如果我直接使用其端口启动.net核心应用程序,它可以正常工作。

I am getting 502.5 response and in event viewer there is this message 我得到502.5响应,并在事件查看器中有此消息

Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE' with physical root 'C:\inetpub\wwwroot\' failed to start process with commandline ' ', ErrorCode = '0x80070057 : 0.

I have removed parent handlers in .net web.config like this 我已经删除了.net web.config中的父处理程序

<handlers>
            <remove name="httpPlatformHandler"/>
            <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
            <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        </handlers>

In order to run an ASP.NET Core application make sure you: 要运行ASP.NET Core应用程序,请确保:

  • Have the ASP.NET Core Web Hosting Bundle (required for a server!) 拥有ASP.NET Core Web Hosting Bundle (服务器所需!)
  • Publish your application - should include a web.config 发布您的应用程序 - 应包含web.config
  • Deploy the Publish output to your server 将“发布”输出部署到服务器
  • Set up an Application Pool 设置应用程序池
  • Set .NET Framework to none (optional but usually a good idea) 将.NET Framework设置为none(可选但通常是个好主意)
  • Use an account that has read permissions in the virtual folder 使用在虚拟文件夹中具有读取权限的帐户

The hosting bundle includes the ASP.NET Core Module for IIS which allows IIS to launch. 托管软件包包括IIS的ASP.NET核心模块,允许IIS启动。 Without ASP.NET Core apps will not run on IIS. 没有ASP.NET核心应用程序将无法在IIS上运行。

You also need to publish your application, which produces a final output folder that contains your binaries and config files including a web.config in the root and a wwwroot root folder with your content. 您还需要发布应用程序,该文件夹生成一个包含二进制文件和配置文件的最终输出文件夹,包括根目录中的web.config和包含内容的wwwroot根文件夹。 To test you should make sure you can run your app from the command line with: 要测试你应该确保你可以从命令行运行你的应用程序:

dotnet yourMainAssembly.dll -c Release

If this doesn't work fix this first as this is essentially what IIS fires. 如果这不起作用,请首先修复此问题,因为这基本上是IIS触发的内容。 once the standalone works you can try using IIS. 一旦独立工作,您可以尝试使用IIS。

ASP.NET Core projects created in Visual Studio automatically include a web.config and that should have everything you need to run under IIS. 在Visual Studio中创建的ASP.NET Core项目自动包含web.config,并且应该包含在IIS下运行所需的所有内容。 For a basic setup that should be all you need. 对于基本设置,应该是您所需要的。 The generated web.config should take care of getting your app running. 生成的web.config应该负责让您的应用运行。

If you're using a virtual you might have an issue with the parent side configuration bleeding into your virtual because virtuals inherit settings from the parent. 如果您正在使用虚拟,则可能会遇到父端配置出现问题的问题,因为虚拟从父级继承设置。 If that's the case either choose the same version of .NET Framework for your application pool, or share the application pool with the parent. 如果是这种情况,请为您的应用程序池选择相同版本的.NET Framework,或与父级共享应用程序池。 Alternately you can use <clear /> in the <handlers> section to clear out any handlers from up the hierarchy. 或者,您可以使用<clear /> <handlers>部分中的<clear />清除层次结构中的任何处理程序。

<configuration>
  <system.webServer>
    <handlers>
      <clear>
      <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
      <environmentVariables />
    </aspNetCore>
  </system.webServer>
</configuration>

I have a blog post with a lot more details on hosting on IIS along with some additional configuration for static files here: 我有一篇博文,其中详细介绍了IIS上的托管以及静态文件的一些其他配置:

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

相关问题 .NET CORE IIS 502.5错误 - .NET CORE IIS 502.5 Error 在未发布的完整 IIS 中运行 ASP.NET Core 应用程序会出现 502.5 错误 - Running ASP.NET Core application in full IIS without publishing gives 502.5 error IIS 上的 ASP.NET Core 1.0 错误 502.5 - ASP.NET Core 1.0 on IIS error 502.5 尝试运行ASP .Net Core 2.1 Web应用程序时出现错误502.5 - Getting error 502.5 when trying to run a ASP .Net Core 2.1 Web application 在IIS 10中发布Dotnet Core 2.0 Mvc应用程序时遇到HTTP错误502.5错误 - I am facing HTTP Error 502.5 error while publishing Dotnet core 2.0 mvc application in IIS 10 ASP .Net Core 2自包含部署,在不同的应用程序池标识帐户下,IIS中出现502.5错误 - ASP .Net Core 2 Self Contained Deployment giving 502.5 Error in IIS under different App Pool Identity Account ASP.NET Core无法在IIS上发布,并显示HTTP错误502.5 - ASP.NET Core failed to publish on IIS, gives HTTP error 502.5 ASP.NET Core 2.1 IIS托管错误502.5-无法执行dotnet命令来确定原因 - ASP.NET Core 2.1 IIS hosting error 502.5 - Unable to execute dotnet command to determine cause IIS和ASP.NET:虚拟目录/应用程序 - IIS and ASP.NET: Virtual directory / application ASP.NET 4.5在ASP.NET Core 2.0应用程序下的Azure Web App中作为虚拟应用程序抛出502.5 - ASP.NET 4.5 throws 502.5 as a virtual application in Azure Web App under a ASP.NET Core 2.0 application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM