ASP.NET MVC6 Beta8 & Windows Authentication

一笑奈何 提交于 2019-12-09 17:41:06

问题


After upgrading to Beta 8, debugging using the windows authentication doesn't work in IIS Express. I am getting an error

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

Steps to reproduce:.

  1. Create a new project and choose Empty web template.
  2. In the project settings, change the IIS Express settings to use Windows Authentication. Uncheck the anonymous authentication.
  3. Enable SSL.
  4. Debug the project.
  5. Error comes up.

I am using new installation of Windows and Visual Studio. Do I need to download any additional software apart from the installation files?


回答1:


As noted in the comments, there is an open tooling issue for this bug. In the mean time, I've been able to successfully debug using WebListener which needs the following two changes:

In Startup.cs

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

and in the Configure method add:

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

In project.json add a new weblistener command as follows:

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

and ensure you have WebListener in your dependencies section

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

As I was upgrading from beta 7, I had to change my hosting.ini file into json format - don't know if that's important or not!

Once this is done, you should be able to debug using weblistener instead of IIS Express. Using web (i.e. kestrel) to debug does not work, as kestrel does not (and will not) support NTLM authentication.

I found that if I changed the "web" command directly in project.json, Visual Studio helpfully changes it back to kestrel rather aggressively, so adding a separate command as recommended by the Microsoft team seems to keep everything happy.



来源:https://stackoverflow.com/questions/33192887/asp-net-mvc6-beta8-windows-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!