protected
void Application_AuthenticateRequest(Object sender, EventArgs e)
![](http://static.javashuo.com/static/loading.gif)
{
![](http://static.javashuo.com/static/loading.gif)
HttpCookie authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie ==
null || authCookie.Value == "")
![](http://static.javashuo.com/static/loading.gif)
{
return;
![](http://static.javashuo.com/static/loading.gif)
}
![](http://static.javashuo.com/static/loading.gif)
FormsAuthenticationTicket authTicket =
null;
try
![](http://static.javashuo.com/static/loading.gif)
{
![](http://static.javashuo.com/static/loading.gif)
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
![](http://static.javashuo.com/static/loading.gif)
}
catch
![](http://static.javashuo.com/static/loading.gif)
{
return;
![](http://static.javashuo.com/static/loading.gif)
}
string[] roles = authTicket.UserData.Split(
new
char[] { ';' });
if (Context.User !=
null)
![](http://static.javashuo.com/static/loading.gif)
{
![](http://static.javashuo.com/static/loading.gif)
Context.User =
new System.Security.Principal.GenericPrincipal(Context.User.Identity, roles);
![](http://static.javashuo.com/static/loading.gif)
}
![](http://static.javashuo.com/static/loading.gif)
}