使用asp.net核心进行Windows身份验证

Jig*_*gar 9 .net-core asp.net-core

请提供有关如何在ASP.NET Core RC2 +上实现Windows身份验证的指导.

我看到其他SO问题描述了承载身份验证,例如使用ASP.NET Core RC2 404而不是403的承载身份验证

但这不是我想要的.

Iva*_*nov 8

您可以使用WebListener执行此操作,如下所示:

  1. 打开project.json并将WebListener添加到依赖项:

    "dependencies" : {
      ...
      "Microsoft.AspNetCore.Server.WebListener": "0.1.0-rc2-final"
      ...
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 将WebListener添加到命令(再次在Project.json中)

      "commands": {
        "weblistener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener"
      },
    
    Run Code Online (Sandbox Code Playgroud)
  3. 在Startup.cs中,指定WebHostBuilder以将WebListener与NTLM一起使用

     var host = new WebHostBuilder()
            // Some configuration
            .UseWebListener(options => options.Listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM)
            // Also UseUrls() is mandatory if no configuration is used
            .Build();
    
    Run Code Online (Sandbox Code Playgroud)

而已!

  • 不可以.目前,IIS和WebListener都只能在Windows上托管.NET Core应用程序.请查看以下链接以获取ASP.NET团队的官方文档https://docs.asp.net/en/latest/fundamentals/servers.html#weblistener (3认同)