tags:

views:

86

answers:

2

The project template for ASP.NET-MVC includes an AccountController that contains the following piece of code

protected override void OnActionExecuting(ActionExecutingContext filterContext) {
    if (filterContext.HttpContext.User.Identity is WindowsIdentity) {
        throw new InvalidOperationException("Windows authentication is not supported.");
    }
}

What is it for?

+1  A: 

For information on the method, see the MSDN reference.

The override you are referring to is throwing an exception if the website has been set up to use Windows authentication, in effect preventing this being used as a method of authentication.

AdamRalph
do you know why it is not supported?
Mikeon
It's just the way the template is set up. You can use Windows authentication with MVC if you want. See http://www.asp.net/learn/mvc/tutorial-18-cs.aspx
AdamRalph
+1  A: 

The template is set up for FormsAuthentication. This ensures that a WindowsIdentity cannot successfully authenticate.

tvanfosson