asp.net 5 中的 Windows 身份验证 [英] Windows authentication in asp.net 5

查看:45
本文介绍了asp.net 5 中的 Windows 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 ASP .NET 5、MVC 6 中构建 Intranet 应用程序.我想知道如何启用 Windows 身份验证.?默认项目模板仅支持个人用户帐户.

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 Accounts.

推荐答案

Mark 的回答在 ASP.Net RC1 中仍然有效.还有一些额外的步骤可以将它们联系在一起(我没有足够的声誉来评论他的解决方案):

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. 从 NuGet 安装 WebListener
  2. 在 Startcup.cs 中添加以下用途:

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

using Microsoft.AspNet.Http.Features;
using Microsoft.Net.Http.Server;

  • 在app.UseMvc之前的Configure方法中添加Mark的代码片段:

    // 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;
    }
    

  • 要对此进行调试,您需要在 project.json添加 WebListener 运行目标/code>,正如马克在另一个答案中指出的:

  • 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"
    },
    

  • 选择 weblistener 而不是 IIS Express of web (Kestrel) 来调试您的应用程序.

  • Pick weblistener instead of IIS Express of web (Kestrel) to debug your application.

    这篇关于asp.net 5 中的 Windows 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆