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 ?
On the taskbar, click Start, and then click Control Panel. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off. Expand Internet Information Services, then World Wide Web Services, then Security. Select Windows Authentication, and then click OK.
By default MVC apps use Form Authentication and Simple Membership, so you need to make it "false" to run Windows Authentication. Select the project name in Solution Explorer and then in the Property Explorer, click to enable Windows Authentication.
In the IIS Manager: Expand the computer name, then Sites, then Default Web Site, then click on the name of the desired site. Select Authentication. Set Windows Authentication to Disabled and set Basic Authentication to Enabled.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With