代码之家  ›  专栏  ›  技术社区  ›  Berger

ASP。net Core WebAPI未在IIS之后启动

  •  3
  • Berger  · 技术社区  · 8 年前

    我正在尝试托管ASP。net Core WebAPI(如Microsoft Docs)告诉我: Hosting in ASP.NET Core

    配置

    我正在Windows Server 2016上运行IIS 10,其中Web部署3.6。Net Core Runtime 2.0.7和。已安装NET Core服务器托管捆绑包。

    Web API配置如下:

    程序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();
    }
    

    网状物配置:

    <?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应用程序。

    2 回复  |  直到 8 年前
        1
  •  4
  •   Community Mohan Dere    5 年前

    在同事的帮助下,我想出了解决方案:

    权限:

    IIS必须对站点文件夹具有权限。必须检查applicationpool用户是否对这些文件夹拥有权限。

    我已经在我的所有站点所属的“C:\inetpub\sites”文件夹以及我正在使用的应用程序池上授予了“本地服务”。

    网状物配置

    WebDeploy已覆盖web。配置并将其更改为:

    <aspNetCore processPath=".\Agent.DuZu.Web.exe" 
        arguments=".\Agent.DuZu.Web.dll"
        stdoutLogEnabled="true" 
        stdoutLogFile=".\logs\stdout" 
        forwardWindowsAuthToken="false" />
    

    因此,标准输出日志显示了一个参数错误。 解决此问题的方法是将processPath更改为“dotnet”,如中所述 question

    <aspNetCore processPath="dotnet" 
        arguments=".\Agent.DuZu.Web.dll"
        stdoutLogEnabled="true" 
        stdoutLogFile=".\logs\stdout" 
        forwardWindowsAuthToken="false" />
    

    另一件需要提及的事情是,必须创建“logs”文件夹,因为IIS本身不会这样做。

        2
  •  2
  •   JessieArr    6 年前

    我在一个新项目中也遇到了这种情况,其中模块被指定为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>