简体   繁体   English

发布到 IIS 后 .Net 核心服务不可用

[英].Net core Service Unavailable after Publish to IIS

After I published my up to IIS when I try to access it I get the error: Service Unavailable当我尝试访问它时将我的 up 发布到 IIS 后,我收到错误:服务不可用

HTTP Error 503. The service is unavailable. http错误503服务不可用。

What should I do next?我接下来该怎么做?

I use Windows Server 2008(64 - bit) with IIS 8.5.我使用带有 IIS 8.5 的 Windows Server 2008(64 位)。 The app is web api .NET CORE 2.2.1.该应用程序是 web api .NET CORE 2.2.1。

On the Windows machine I have installed:在我安装的 Windows 机器上:

  • Microsoft .NET CORE 2.2.1 - Windows Server Hosting Microsoft .NET CORE 2.2.1 - Windows 服务器托管
  • Microsoft .NET CORE Runtime - 2.2.1(x64) Microsoft .NET CORE 运行时 - 2.2.1(x64)
  • Microsoft .NET CORE Runtime - 2.2.1(x86) Microsoft .NET CORE 运行时 - 2.2.1(x86)
  • Microsoft Visual C++ 2015 Redistributable(x86) - 14.024212 Microsoft Visual C++ 2015 Redistributable(x86) - 14.024212
  • Microsoft Visual C++ 2015 Redistributable(x64) - 14.024123 Microsoft Visual C++ 2015 Redistributable(x64) - 14.024123
  • Microsoft Visual C++ 2008 Redistributable - x86 - 9.0.30729.4148 Microsoft Visual C++ 2008 Redistributable - x86 - 9.0.30729.4148
  • Microsoft Visual C++ 2008 Redistributable - x64 - 9.0.30729.6161 Microsoft Visual C++ 2008 Redistributable - x64 - 9.0.30729.6161

I made a publication from the visual studio.我从视觉工作室发表了一篇文章。 Into IIS on modules i have AspNetCoreModuleV2.在模块上进入 IIS 我有 AspNetCoreModuleV2。

The webconfig file I have:我拥有的 webconfig 文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\App.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
   </system.webServer>
 </location>
</configuration>
<!--ProjectGuid: 9d04b7be-318b-4e95-aae3-c47aab07db30-->

Code from CreateWebHostBuilder Method: CreateWebHostBuilder 方法中的代码:

 return WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>().UseSerilog((ctx, cfg) =>
            {
                cfg.ReadFrom.Configuration(ctx.Configuration)
                    .MinimumLevel.Verbose()
                    .MinimumLevel.Override("Microsoft", LogEventLevel.Information);
            });

you can check below steps to dedect issue.您可以检查以下步骤来检测问题。

  1. ensure .net core runtime and AspNetCoreModule are installed And operating system restarted after installations .确保 .net core 运行时和 AspNetCoreModule 已安装并在安装后重新启动操作系统
  2. ensure your application pool .Net framework version is "No Managed Code" on iis.确保您的应用程序池 .Net 框架版本在 iis 上为“无托管代码”。
  3. ensure that your application warming up properly.确保您的应用程序正确预热。 (open command prompt in directory where your application. type dotnet yourapp.dll and then press enter.) (在应用程序所在的目录中打开命令提示符。键入dotnet yourapp.dll ,然后按 Enter。)
  4. If you have your application running under an IIS and you set a binding with https, you need to specify a url with the SSL certificate associated to it, when you run dotnet yourapp.dll by default it will run on localhost if you don't specify on your Program.cs a call to UseUrls.如果您的应用程序在 IIS 下运行并设置了与 https 的绑定,则需要指定一个带有与其关联的 SSL 证书的 url,当您运行dotnet yourapp.dll ,默认情况下它将在 localhost 上运行,如果您不这样做在 Program.cs 上指定对 UseUrls 的调用。 Then you can call your dotnet yourapp.dll and it will work然后你可以调用你的dotnet yourapp.dll并且它会工作

    var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() .UseUrls(" http://mywebsite.com ") .Build(); var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() .UseUrls(" http://mywebsite.com ") .Build();

  5. if app starting properly with dotnet command check access level of log file location(".\\logs\\stdout").如果应用程序使用 dotnet 命令正确启动,请检查日志文件位置的访问级别(“.\\logs\\stdout”)。 To give the applicationpool user the ability to read and write, perform the following steps https://stackoverflow.com/a/7334485/4172872要让应用程序池用户能够读写,请执行以下步骤https://stackoverflow.com/a/7334485/4172872

UPDATE:更新:

Is the extension of the application really ".exe"?应用程序的扩展名真的是“.exe”吗?

<aspNetCore processPath=".\App.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />

Also this https://github.com/dotnet/aspnetcore/issues/10117 - it's an ongoing open issue with .NET Core还有这个https://github.com/dotnet/aspnetcore/issues/10117 - 这是 .NET Core 的一个持续开放的问题

This was not an issue with the "old" ASP.NET because it was able to "overlap" requests into two process :(这不是“旧”ASP.NET 的问题,因为它能够将请求“重叠”到两个进程中:(

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM