简体   繁体   English

承载 ASP 核心 API 的 IIS

[英]IIS hosting an ASP Core API

Got the following issue with a Web API I've been working on, my issue lies within how am I supposed to configure the Web API to work with IIS (Windows Server 2012 R2) considering the fact that I've been following this document's directions and I still get 'This page can't be displayed' browser error :得到了下面的问题与Web API我一直在工作,我的问题就在于内我应该如何在Web API与IIS(在Windows Server 2012 R2),考虑到我一直在关注这个文件的事实配置为工作方向我仍然收到“无法显示此页面”浏览器错误:

The Windows Server is hosted on Azure. Windows Server 托管在 Azure 上。

I've even added this part related to IIS authentication (thought that this may not cause my issue), adding/removing it has no effect whatsoever.我什至添加了与 IIS 身份验证相关的这部分(认为这可能不会导致我的问题),添加/删除它没有任何影响。

 public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddOptions();

        services.Configure<IISOptions>(options =>
        {
            options.ForwardWindowsAuthentication = false;
        });
     }

As in how I've created my publish folder I've proceeded as following :就像我创建publish文件夹的方式一样,我进行了如下操作:

dotnet publish

This caused the following folder structure这导致以下文件夹结构

  • refs参考
  • runtimes运行时
  • lots of .dll's (references to various assemblies such as aspnetcore.mvc, httpclient,etc)许多 .dll(对各种程序集的引用,例如 aspnetcore.mvc、httpclient 等)
  • web.config网页配置
  • mywebAPI.deps (json file with dependencies) mywebAPI.deps(带有依赖项的 json 文件)
  • mywebAPI.dll我的webAPI.dll
  • mywebAPI.pdb mywebAPI.pdb
  • appsettings.JSON appsettings.JSON

According to thedirectory structure I do miss wwwroot and Views because I have them implicitly mentioned in my project.json , but I don't need them since I have a web api and not a web form app.根据目录结构,我确实错过了 wwwroot 和 Views,因为我在project.json隐式提到了它们,但我不需要它们,因为我有一个 web api 而不是 web 表单应用程序。

"publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  }

Configuring steps on IIS Created a folder on the main drive where I've placed the result of the publish.在 IIS 上配置步骤 在我放置发布结果的主驱动器上创建了一个文件夹。 Went to IIS Manager and added a new website Went to application pool and set the .NET CLR Version to 'No Managed Code'转到 IIS 管理器并添加一个新网站转到应用程序池并将 .NET CLR 版本设置为“无托管代码”

在此处输入图片说明

Launching the app throws me right into this browser error - This page can't be displayed启动应用程序让我直接进入这个浏览器错误 - 此页面无法显示

Running from CMD dotnet mywebapi.dll WORKS... and I've tested it with Postman (have postman on the Windows Server).从 CMD dotnet mywebapi.dll WORKS 运行...我已经用邮递员测试过它(在 Windows 服务器上有邮递员)。

在此处输入图片说明

You need more information.您需要更多信息。

Enable and check the application logs at .\\logs\\stdout ..\\logs\\stdout启用并检查应用程序日志

<system.webServer>
    <handlers>
      <add 
         name="aspNetCore" 
         path="*" 
         verb="*" 
         modules="AspNetCoreModule" 
         resourceType="Unspecified"/>
    </handlers>
    <aspNetCore 
         processPath=".\MyApp.exe" 
         arguments="%LAUNCHER_ARGS%" 
         stdoutLogEnabled="false"                  <--- enable
         stdoutLogFile=".\logs\stdout" />          <--- set path
  </system.webServer>
</configuration>

Check the IIS logs (you probably do NOT have to enable them first).检查 IIS 日志(您可能不必先启用它们)。 Event Viewer > Windows Logs > Application.事件查看器 > Windows 日志 > 应用程序。 To drill down, you can Filter Current Log... by Event level et cetera.要向下钻取,您可以按事件级别等过滤当前日志...。

IIS 应用程序日志

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM