可以通过控制台而不是通过IIS承载ASP.NET Core网站

Jes*_*lam 5 iis .net-core asp.net-core visual-studio-2017

解决方案和服务器配置:

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

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

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

我的服务器是Windows Server 2012 R2,具有所有相关的Service Pack和更新。已安装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
Run Code Online (Sandbox Code Playgroud)

解决步骤:

不用说,我已经按照指示进行了解决。给定的链接在“ 平台与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.
Run Code Online (Sandbox Code Playgroud)

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

Program.cs的如下:

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

host.Run();
Run Code Online (Sandbox Code Playgroud)

Startup.cs的大部分没兴趣。除了一些服务定义,我的管道是:

app.UseCookieAuthentication();
app.UseRedditMiddleware(); // authentication middleware, custom
app.UseMvc();
app.UseStaticFiles();
Run Code Online (Sandbox Code Playgroud)

Paw*_*wel 5

未设置到dotnet文件夹的系统范围的%PATH%(IIS以其他用户身份运行),或者在安装ASP.Net Core Server捆绑包后没有重新启动服务器。您可以在我的文章中找到更多有关使用IIS运行ASP.NET Core应用程序的疑难解答步骤。