繁体   English   中英

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

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

当我尝试访问它时将我的 up 发布到 IIS 后,我收到错误:服务不可用

http错误503服务不可用。

我接下来该怎么做?

我使用带有 IIS 8.5 的 Windows Server 2008(64 位)。 该应用程序是 web api .NET CORE 2.2.1。

在我安装的 Windows 机器上:

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

我从视觉工作室发表了一篇文章。 在模块上进入 IIS 我有 AspNetCoreModuleV2。

我拥有的 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-->

CreateWebHostBuilder 方法中的代码:

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

您可以检查以下步骤来检测问题。

  1. 确保 .net core 运行时和 AspNetCoreModule 已安装并在安装后重新启动操作系统
  2. 确保您的应用程序池 .Net 框架版本在 iis 上为“无托管代码”。
  3. 确保您的应用程序正确预热。 (在应用程序所在的目录中打开命令提示符。键入dotnet yourapp.dll ,然后按 Enter。)
  4. 如果您的应用程序在 IIS 下运行并设置了与 https 的绑定,则需要指定一个带有与其关联的 SSL 证书的 url,当您运行dotnet yourapp.dll ,默认情况下它将在 localhost 上运行,如果您不这样做在 Program.cs 上指定对 UseUrls 的调用。 然后你可以调用你的dotnet yourapp.dll并且它会工作

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

  5. 如果应用程序使用 dotnet 命令正确启动,请检查日志文件位置的访问级别(“.\\logs\\stdout”)。 要让应用程序池用户能够读写,请执行以下步骤https://stackoverflow.com/a/7334485/4172872

更新:

应用程序的扩展名真的是“.exe”吗?

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

还有这个https://github.com/dotnet/aspnetcore/issues/10117 - 这是 .NET Core 的一个持续开放的问题

这不是“旧”ASP.NET 的问题,因为它能够将请求“重叠”到两个进程中:(

暂无
暂无

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

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