I use an initializer DropCreateDatabaseAlways, so my database gets destroyed every time the application starts (at least I hope). The funny thing is that I still see myself logged in. I get an attribute Authorizeand can do dangerous things. This is probably due to the remaining cookies from previous testing.
The registration / login part of my application is the MVC 4 web application template, not affected. Should ASP.NET check cookie values for users stored in the database? WebSecurity.IsAuthenticatedreturns true, and WebSecurity.CurrentUserNamereturns a name. The only thing that works is expected WebSecurity.CurrentUserId, which returns -1. I'm a newbie, so I can only guess that this is because it is UserIdnot stored in a cookie and needs to be retrieved from the database.
I'm right? If so, does this mean that I should always use WebSecurity.CurrentUserIdto determine if the user is logged in? WebSecurity.IsAuthenticatedand User.Identity.IsAuthenticatedseem useless in this case. I can delete the user account and he or she remains unaffected. What to do differently if I am mistaken?
source
share