【问题标题】:AspNetCoreModule - HTTP Error 502.3AspNetCoreModule - HTTP 错误 502.3
【发布时间】:2017-01-29 19:48:45
【问题描述】:

我有一个 .Net Core 1.1.0 网络应用程序。我一直在愉快地使用 IISExpress 和 Visual Studio 进行构建和调试。现在我想发布应用程序并将其托管在我自己的普通 IIS 后面的 Web 服务器上。

步骤:

  1. 运行dotnet publish,它将所有内容打包到发布中 文件夹
  2. 在 IIS 中创建了一个新的应用程序池,并将 .NET CLR 版本设置为 “无托管代码”
  3. 在默认网站下创建了一个新应用程序, 使用新的应用程序池,物理路径设置为发布 在第 1 步中创建的文件夹。

在尝试访问该站点的 URL 时,我收到 HTTP Error 502.3 - Bad Gateway,表示错误来自的模块是 AspNetCoreModule。

这是将应用程序池的托管管道模式设置为集成。如果我将它设置为经典,我会得到 502.5 - 进程失败。 Windows 事件日志没有任何用处。

这是应用程序的 web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

编辑:这是 WebHostBuilder 定义:

var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .ConfigureServices(s => s.AddRouting())
            .Configure(app =>
            {
                SetupRoutes(app);
                app.UseDefaultFiles();
                app.UseStaticFiles();
            })
            .Build();
        host.Run();

【问题讨论】:

  • 您在使用 Kestrel 吗?显示您的 WebHostBuilder 定义
  • 认为我发现了问题。我使用 VS 2017 添加了 nuget 包(所以在 .csproj 中,但在 project.json 中没有) - 从命令行发布失败,因为它找不到它们。我现在可以在 IIS 中看到该站点。仍然有点困惑,因为 CLI 发布之前工作过......
  • 从您发布应用的文件夹中运行 dotnet myapp.dll。一切都开始/工作正常吗?如果是 - 问题只有“真正的 IIS”。编辑web.config,将stdoutLogEnabled更改为true,重启应用,刷新浏览器页面,查看logs\stdout下的日志文件。
  • @Dmitry 我可以在控制台中运行dotnet myapp.dll,它会启动并提供服务。看起来我的 IIS 是问题所在。我启用了stdout 日志,但它创建的文件都是空白的。我收到 502.3 Bad Gateway - 尝试路由请求时出现连接错误,错误代码:0x800700002。我到处搜索,仍然是,但无法弄清楚问题是什么。模块不好?我已经重新安装了它。我被难住了。
  • 我的问题是 HttpPlatformHandler 1.0,需要安装 1.2。 stackoverflow.com/questions/33255222/…

标签: .net iis asp.net-core .net-core


【解决方案1】:

您是否安装了正确的运行时环境?

https://www.microsoft.com/net/download/core#/current/runtime

您的 web.config 指向一个模块 AspNetCoreModule,您能在 IIS 下的应用程序的“模块”列表中看到它正确安装吗?

【讨论】:

  • 我可以在模块列表中看到我的模块并且它已启用。这是否意味着它已正确安装?我确实安装了所有环境。
猜你喜欢
  • 2017-09-11
  • 1970-01-01
  • 1970-01-01
  • 2017-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-07
  • 1970-01-01
相关资源
最近更新 更多