C# ASP.net核心WebAPI未在IIS之后启动
我正在尝试托管一个ASP.net核心WebAPI,如Microsoft Docs告诉我的:C# ASP.net核心WebAPI未在IIS之后启动,c#,iis,asp.net-core,iis-10,C#,Iis,Asp.net Core,Iis 10,我正在尝试托管一个ASP.net核心WebAPI,如Microsoft Docs告诉我的: 配置 我在Windows Server 2016上运行IIS 10,其中安装了Web Deploy 3.6、.Net Core Runtime 2.0.7和.Net Core Server托管捆绑包 Web API的配置如下所示: Program.cs: public static IWebHost BuildWebHost(string[] args) { IConfigurationRoot
配置 我在Windows Server 2016上运行IIS 10,其中安装了Web Deploy 3.6、.Net Core Runtime 2.0.7和.Net Core Server托管捆绑包 Web API的配置如下所示: Program.cs:
public static IWebHost BuildWebHost(string[] args) {
IConfigurationRoot config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
return WebHost.CreateDefaultBuilder(args)
.UseConfiguration(config)
.UseStartup<Startup>()
.UseKestrel(opt => {
opt.Listen(IPAddress.Loopback, 4000);
})
.UseIISIntegration()
.Build();
}
公共静态IWebHost BuildWebHost(字符串[]args){
IConfigurationRoot config=new ConfigurationBuilder()
.SetBasePath(目录.GetCurrentDirectory())
.AddJsonFile(“appsettings.json”)
.Build();
返回WebHost.CreateDefaultBuilder(args)
.UseConfiguration(配置)
.UseStartup()
.UseKestrel(选项=>{
选择侦听(IPAddress.Loopback,4000);
})
.Useii整合()
.Build();
}
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=".\Agent.DuZu.Web.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
在IIS上,ASP.net核心模块被激活,我有一个在端口80上绑定的站点
问题
我正在使用WebDeploy在服务器上发布应用程序,但应用程序无法启动。没有输出,也没有错误。我不确定我是否遗漏了什么,或者我的配置是否只是失败了。
我还想知道,是否有办法查看running应用程序。在同事的帮助下,我找到了解决方案: 权限: IIS必须对站点文件夹具有权限。必须检查applicationpool用户是否具有对文件夹的权限 我已在我所有站点所属的“C:\inetpub\sites”文件夹以及我正在使用的应用程序池上授予“本地服务” web.config WebDeploy已覆盖web.config并将其更改为:
<aspNetCore processPath=".\Agent.DuZu.Web.exe"
arguments=".\Agent.DuZu.Web.dll"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false" />
另一件需要提及的事情是,必须创建“logs”文件夹,因为IIS本身不会这样做。我在一个新项目中也遇到过这种情况,其中模块被指定为AspNetCoreModuleV2:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
大概我没有安装它。我在我的一个旧的.NET核心网站上看到,这个模块不是V2。从模块规范中删除V2在我的实例中修复了它:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
您是否已验证所有文件都是通过WebDeploy传输的。如果使用FTP传输文件,是否也会发生同样的情况?所有文件都将在服务器上卸载。我也尝试过FTP,同样的行为。错误消息到底是什么?@TanveerBadar这就是问题所在,没有错误消息。它只是将文件放在那里,什么也没有发生。您是否尝试安装SDK只是为了确保它与缺少的依赖项无关?如果没有错误,很难推断出发生了什么。您的web.config与我正在使用的web.config完全相同。。
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>