I am creating a brand new projet with Visual Studio 2013, I choose Asp.Net MVC and the framework 4.5.1 The project is created, then, I do nothing else than F5 to start the d
These answers are more or less pieces of the same puzzle; I'll try to put everything in one place. Problem that OP described hit my application the moment I implemented the OWIN pipeline and AspNET Identity.
So let's see how to fix it...
I guess you need it, because if you don't, then you don't need authentication, and I guess you do. Except it you're using some old-style authentication, and I guess you don't. So, don't remove either the OWIN startup attribute...
[assembly: OwinStartupAttribute(typeof(YourApp.Probably_App_Start.SomethingLikeAuthConfig))]
...or the configuration line...
Now we cleared this up, you need the authentication. This means either each of your controller needs the [Authorize]
attribute, or you can do the same to all controllers in one place by registering the thing globally (e.g. in RegisterGlobalFilters()
, add line filter.Add(new AuthorizeAttribute())
).
In the former case (when securing each controller separately) skip this part, just go to the next one.
In the latter case all of your controllers will be secured against unauthorized acces, so you need an entry point for that authorization - unprotected Login()
action.
Just add...
[AllowAnonymous]
...and you should be good.
When your user logs in, his browser stores encrypted (hopefully!) cookie in order to simplify things for the system. So, you need cookie - don't delete the line that says UseCookieAuthentication
.
Windows Authentication
(Disabled) and enable letting any user in, at least as long as IIS Express is now concerned, by setting Anonymous Authentication
(Enabled).When you start your web site, this will in turn copy these settings into IIS Express configuration (applicationhost.config
), and there you should see these two lines:
You might have the authorization config in your web.config that says deny users="?"
. It means the authorization subsystem is instructed to prevent anonymous users from entering.
With OWIN, this still works as designed. You either have to remove this, or make your anonymous user able to access the Login page by using something like...
HTH