【问题标题】:Can host ASP.NET Core site through console but not through IIS可以通过控制台托管 ASP.NET Core 站点,但不能通过 IIS
【发布时间】:2017-05-30 20:08:36
【问题描述】:

解决方案和服务器配置:

我开发了一个相当简单的 ASP.NET Core 应用程序。它由一个核心项目文件组成,在 Visual Studio 2017 中创建和构建。目标框架为.NETCoreApp 1.1,平台目标为x64

它还包含两个类库项目,目标框架.NETStandard 1.4 和平台目标x64

由于 VS2017 的 Web Deploy 中的错误,我正在发布到文件系统,然后使用 FTP 将 PublishOutput 的内容复制到我的 IIS 应用程序目录。

我的服务器是带有所有相关服务包和更新的 Windows Server 2012 R2。已安装 DotNet Core 运行时。

问题:

当我在浏览器中导航到我网站的 URL 时,我遇到一个平淡无奇的 HTML 页面,其中显示以下内容:

HTTP Error 502.5 - Process Failure

Common causes of this issue: (lists things)
Troubleshooting steps: (lists things)
For more information visit http://go.microsoft.com/fwlink/?linkid=808681

解决步骤:

不用说,我已经按照说明解决了。 The link given 在 Platform conflict with RID 标题下显示了我的错误。

事件查看器有一个带有以下内容的错误条目:

Application 'MACHINE/WEBROOT/APPHOST/MY SITE' with physical root 'C:\inetpub\wwwroot\mysite\' failed to start process with commandline "dotnet" .\MySite.dll', ErrorCode = '0x80070002 : 0.

通过在我的站点文件夹中打开cmd.exe 的实例,我可以执行dotnet mysite.dll 并运行它,托管在http://localhost:5000 上。正如预期的那样,我可以在浏览器中导航到该站点。

我的Program.cs如下:

var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

host.Run();

我的Startup.cs 大多无趣。除了一些服务定义,我的管道是:

app.UseCookieAuthentication();
app.UseRedditMiddleware(); // authentication middleware, custom
app.UseMvc();
app.UseStaticFiles();

【问题讨论】:

    标签: iis asp.net-core .net-core visual-studio-2017


    【解决方案1】:

    dotnet 文件夹的系统范围 %PATH% 未设置(IIS 以其他用户身份运行),或者您在安装 ASP.Net Core Server 捆绑包后未重新启动服务器。您可以在我的帖子about running ASP.NET Core applications with IIS 中找到更多故障排除步骤。

    【讨论】:

    • 你是对的。安装后我确实没有重新启动我的服务器,因为在托管其他租户之后我不想停机。重新启动后,网站正常工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    相关资源
    最近更新 更多