Home » x Other Posts » Set up a public page in a website protected by Windows Authentication

Set up a public page in a website protected by Windows Authentication

If all of the pages in your website is protected by Windows Authentication, it may be tricky to let your users access a page that should be publicly accessible (FAQ page, Terms & Conditions page, etc.). In this post, I will mention the configuration you should implement to enable public access to certain pages.

Solution for creating a public page in a website with Windows Authentication

The idea is to protect the entire website and create an exception for the public page. Here are the steps:

  • Enable Windows Authentication and disable Anonymous Authentication in IIS Manager (This is how the Windows Authentication should be set. Anonymous Authentication should be disabled)
  • In the web.config file, use location tag to allow Anonymous access to a certain page

Here are the lines to add to web.config file:

            <allow users="*" />
            <deny users="?" />

<location path="test”>
                <anonymousAuthentication enabled="true" />

     <modules runAllManagedModulesForAllRequests="true" />

With this configuration, we are allowing anonymous access to the test folder only.

Set runAllManagedModulesForAllRequests parameter to true for making sure the managed modules process all requests (official documentation).

The page may throw an error like the one below about not being able to override the authentication settings.

500.19 configuration section

If you run into this issue, go to applicationHost.config file and set overrideModeDefault to Allow. Check this post out for more details: Prevent settings to be overridden by web.config (HTTP Error 500.19)

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.

Leave a Comment