Вопрос

Environment: MVC3 SqlMemberShipProvider

I added an empty

public void Application_AuthenticateRequest(object sender, EventArgs e) {}

in the MvcApplication class in Global.asax.cs and put a breakpoint there. It was fired on every page access. The sender is of type MvcApplication, which has a User property and a Context property.

If I am not logged in, User and Context.User are null.

If I am logged in, User and Context.User are set to a GenericPrincipal containing my logged in name.

So it seems that SqlMemberShipProvider (if not who) is setting the User object. May I know how/where this is done?

Thanks.

Это было полезно?

Решение

I guess you are using Membership together with FormsAuthentication? Maybe together with login control? If you are using FormsAuthentication then it is FormsAuthenticationModule that reads the identity cookie from the browser and then constructs the IPrincipal object from that cookie.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top