gpt4 book ai didi

iis - 可以通过控制台托管 ASP.NET Core 站点,但不能通过 IIS

转载 作者:行者123 更新时间:2023-12-02 12:32:34 26 4
gpt4 key购买 nike

解决方案和服务器配置:

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

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

由于 VS2017 的 Web 部署中的错误,我正在发布到文件系统,然后使用 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给定的错误显示在平台与 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://本地主机: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();

最佳答案

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

关于iis - 可以通过控制台托管 ASP.NET Core 站点,但不能通过 IIS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41668727/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com