Search code examples
asp.net-mvc-3iiswindows-authenticationanonymous-access

How do I allow anonymous access to my mvc3 app using Windows Authentication


I have an MVC3 Intranet app that uses Windows authentication. I'm now using a third party service that will make notification calls to my app. I've already created a listener for these API calls but not sure how I can allow anonymous access to that single view in my app.

My IIS7 settings are as follows:

Anonymous - Enabled <---------- Use Domain User
ASP.NET Impersonation - Disabled
Basic Authentication - Disabled
Digest Authentication - Disabled
Forms Authentication - Disabled
Windows Authentication - Enabled - HTTP 401 Challange

Additionally, in my web.config file, authentication mode is set to Windows.

With that said, is there a way to allow anonymous access to a single view in my MVC app?


Solution

  • Where path is your end url, add this your web.config.

    <location path="MyController/MyAction">
        <system.web>
            <authorization>
                <allow users="?" />
            </authorization>
        </system.web>
    </location>
    

    Or decorate the action with AllowAnonymousAttibute http://msdn.microsoft.com/en-us/library/system.web.http.allowanonymousattribute(v=vs.108).aspx.