Windows Authentication in web.config in asp.net mvc4
Solution 1
For IIS Express
You can set it up here. You may also wish to disable anonymous access
For IIS
I found it was necessary to set this under system.webServer
<system.webServer>
[…]
<security>
<authentication>
<anonymousAuthentication enabled="false"/>
<windowsAuthentication enabled="true"/>
</authentication>
</security>
</system.webServer>
This does almost the same thing as the @Dimitar suggestion - use IIS Manager to change the setting. The difference is that the config file avoids a manual step - but adds this next one:
Note:
By default, IIS Feature Delegation locks some of those settings (Basic & Windows auth), so you'll need to go to the root of the IIS server, and enable those to be read/write. E.g.:
A more detailed description of accessing Feature Delegation is here.
Solution 2
If by this you mean running your project from Visual Studio (IISExpress - not IIS), then you can try to do the following:
In Visual Studio -> Click on the root of your project -> Press F4 in order to open the properties pane -> Look for "Windows Authentication" and mark is as "Enabled" -> Run your project.
Solution 3
Unfortunately you must use IIS to enable Windows authentication. You cannot do it in Web.config alone. (At least up to IIS 8.5, the current version as of this post.)
This is because the Web.config elements for enabling Windows authentication (<system.webServer><security><authentication><windowsAuthentication>
) can only be defined in applicationHost.config (C:\Windows\System32\inetsrv\config).
Solution 4
If windows authentication is not installed on IIS it won't work. If it is installed setting in web.config should be fine
zrabzdn
Updated on July 19, 2022Comments
-
zrabzdn almost 2 years
I need to enable Windows Authentication from my
web.config
, without setting it in IIS.I have the following elements in the
web.config
:authentication mode="Windows identity impersonate="true
However windows authentication is not working. How do I resolve this problem ?