Visual Studio 2015 vNext and Windows Authentication

How to configure a project to use Windows authentication? Now that there are no web.config files, I don’t see how to do this.

I see app.UseIdentity () in Startup, but don’t know how to use Windows Auth with IIS Express. When I try to create a project in IIS (Windows 7, IIS 7.5), it looks like there is no .NET 4.6 / 4.5 application pool, I tried .NET 4.0, but I get an error message:

Unable to determine the appropriate version of the runtime. See http://go.microsoft.com/fwlink/?LinkId=517742 for more details.

Of course, this link does not lead me to information, but http://www.asp.net/

+6
source share
3 answers

What worked for me in debugging with VS2015:

Open the IIS Express configuration file: %userprofile%\Documents\IISExpress\config\applicationhost.config

There is a line that says:
<windowsAuthentication enabled="false">

Change it to:
<windowsAuthentication enabled="true">

Then I added to my Web.conf:

 <authentication mode="Windows"> </authentication> <authorization> </authorization> 

Then I was able to pull out the Windows username with:
Request.LogonUserIdentity.Name

+6
source

Go to the properties of the web project β†’ Debugging β†’ Part of the IIS Express settings and there uncheck the Enable anonymous authentication check box and select the Enable Windows authentication check box.

The user (in the controllers) will be loaded with local domain data.

http://screencast.com/t/GecnmVnXHC

edit :
We had to enable anonymous authentication because the CORS preview request would not work otherwise (401)

+1
source

There is also a configuration file for IISExpress. See the Guide here: See Using Windows Authentication Using IISExpress

-2
source

Source: https://habr.com/ru/post/984203/


All Articles