ASP.NET MVC6 Beta8 & Windows 身份验证

ASP.NET MVC6 Beta8 & Windows Authentication

升级到 Beta 8 后,使用 windows 身份验证进行调试在 IIS Express 中不起作用。我收到一个错误

"An error occurred attempting to determine the process id of the DNX process hosting your application."

重现步骤:。

  1. 创建一个新项目并选择空网页模板。
  2. 在项目设置中,将 IIS Express 设置更改为使用 Windows 身份验证。取消选中匿名身份验证。
  3. 启用 SSL。
  4. 调试项目。
  5. 出现错误。

我正在使用 Windows 和 Visual Studio 的新安装。除了 installation files,我还需要下载任何其他软件吗?

如评论中所述,有一个 open tooling issue for this bug。与此同时,我已经能够使用需要以下两个更改的 WebListener 成功调试:

Startup.cs

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

并在 Configure 方法中添加:

var listener = app.ServerFeatures.Get<WebListener>(); 
if (listener != null)
{ 
    listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; 
}

project.json中添加一个新的weblistener命令如下:

"commands": {
  "weblistener": "Microsoft.AspNet.Server.WebListener --config hosting.ini",
  "web": "Microsoft.AspNet.Server.Kestrel"
},

并确保您的 dependencies 部分中有 WebListener

"Microsoft.AspNet.Server.WebListener": "1.0.0-beta8",

当我从 beta 7 升级时,我不得不将我的 hosting.ini 文件更改为 json 格式 - 不知道这是否重要!

一旦完成,您应该能够使用 weblistener 而不是 IIS Express 进行调试。使用 web(即 kestrel)进行调试不起作用,因为 kestrel 不(也不会)支持 NTLM 身份验证。

我发现如果我直接在 project.json 中更改 "web" 命令,Visual Studio 会很有帮助地将它改回 kestrel 相当积极,所以添加一个单独的命令 as recommended by the Microsoft team似乎让一切都开心。