Windows authentication in asp.net 5

前端 未结 9 1381
别跟我提以往
别跟我提以往 2020-11-29 08:00

I am building an intranet application in ASP .NET 5, MVC 6. I want to know how to enable Windows Authentication.? The default project template supports only Individual User

相关标签:
9条回答
  • 2020-11-29 08:24

    If you want to enable windows authentication on current web project:

    On the solution explorer, right-clink on website and select "Properties Window"

    Set "Anonymous Authentication" to "Disabled"

    And set "Windows Authentication"

    Run the project and everything will fine.

    0 讨论(0)
  • 2020-11-29 08:25

    Mark's answer is still valid in ASP.Net RC1. There are some additional steps to tie it all together (I don't have enough reputation to comment on his solution):

    1. Install WebListener from NuGet
    2. Add the following usings to Startcup.cs:

      using Microsoft.AspNet.Http.Features;
      using Microsoft.Net.Http.Server;
      
    3. Add Mark's code snippet in the Configure method before app.UseMvc:

      // If we're self-hosting, enable integrated authentication (if we're using
      // IIS, this will be done at the IIS configuration level).
      var listener = app.ServerFeatures.Get<WebListener>();
      if (listener != null)
      {
          listener.AuthenticationManager.AuthenticationSchemes = 
          AuthenticationSchemes.NTLM;
      }
      
    4. To debug this, you need to add the WebListener run target in project.json, as Mark noted in a different answer:

      "commands": {
        "weblistener": "Microsoft.AspNet.Server.WebListener --config hosting.ini",
        "web": "Microsoft.AspNet.Server.Kestrel"
      },
      
    5. Pick weblistener instead of IIS Express of web (Kestrel) to debug your application.

    0 讨论(0)
  • 2020-11-29 08:28

    For RC1 & IISExpress from an empty Web Application:

    • Right click web project, select Properties
    • Click Debug tab, check Enable Windows Authentication

    This affected ~/Properties/launchSettings.json as follows:

    "windowsAuthentication": true,
    "anonymousAuthentication": false,
    
    0 讨论(0)
提交回复
热议问题