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'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):
Add the following usings to Startcup.cs:
using Microsoft.AspNet.Http.Features;
using Microsoft.Net.Http.Server;
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;
}
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"
},
Pick weblistener instead of IIS Express of web (Kestrel) to debug your application.