12

I'm trying to configure the IIS Authentication settings from my MVC5 project in the Web.config file.

Here's what I have. I want Windows Authentication enabled and Anonymous Authentication disabled.

enter image description here

But after publishing my package in IIS, the settings are this.

enter image description here

What do I need to do to also set the Anonymous Authentication to Disabled in the Web.config? Isn't that what <deny users "?"/> is supposed to be doing?

4
  • @mavora, <deny users "?"/> is using to allow only authenticated users Commented May 4, 2016 at 14:17
  • praguan - isn't that the same thing as disallowing anonymous? Commented May 4, 2016 at 14:21
  • @mavora, deny = * means deny everyone; deny = ? means deny unauthenticated users Commented May 4, 2016 at 14:23
  • Thanks. I was assuming that was what changed the Anonymous Authentication setting. Commented May 4, 2016 at 14:24

2 Answers 2

7

Here we go step by step:

  1. Open Internet Information Services (IIS) Manager:

    • If you are using Windows Server 2012 or Windows Server 2012 R2:
    • On the taskbar, click Server Manager, click Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows 8 or Windows 8.1:
    • Hold down the Windows key, press the letter X, and then click Control Panel. Click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
    • If you are using Windows Server 2008 or Windows Server 2008 R2:
    • On the taskbar, click Start, point to Administrative Tools, and then click

      Internet Information Services (IIS) Manager.

    • If you are using Windows Vista or Windows 7:

    • On the taskbar, click Start, and then click Control Panel.
    • Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.

      1. In the Connections pane, expand the server name, expand Sites, and go to the level in the hierarchy pane that you want to configure, and then click the Web site or Web application.
      2. Scroll to the Security section in the Home pane, and then double-click Authentication. 4.In the Authentication pane, select Anonymous Authentication, and then click Disable in the Actions pane.

Or you can disable by config file:

<location path="Contoso">
   <system.webServer>
      <security>
         <authentication>
            <anonymousAuthentication enabled="false" />   <!--This line you need-->
            <basicAuthentication enabled="true" defaultLogonDomain="Contoso" />
            <windowsAuthentication enabled="true" />
          </authentication>
      </security>
   </system.webServer>
</location>

Deny Anonymous user to access entire website:

   <authorization>
    <deny users="?" ></deny>    
    </authorization>

Hope it helps;)

Sign up to request clarification or add additional context in comments.

4 Comments

I see where you got these settings. iis.net/configreference/system.webserver/security/… They do not work and bring up an error in IIS, and I'm excluding the location path and basicaauthentication parts.
@try to use that script where I showed to disable by config file ;)
Sorry, but your first set of code errors out similar to this... stackoverflow.com/questions/28419304/… Your second set of code is what I already have.
I concur with @Madvora, the first set of code doesn't seem to work for me either. Do you have a example of a full web.config with that implemented?
-2

Right click on Anonymous Authentication and click disable

2 Comments

Yeah I know how to change the settings in IIS, I'm trying to set this in the Web.config and wondering why my settings there don't translate.
It only works when you run locally(through VS),but for IIS, you need to disable it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.