Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Application_AcquireRequestState(object sender, EventArgs e)
- {
- var httpContext = HttpContext.Current;
- var session = httpContext.Session;
- if (User.Identity.IsAuthenticated && session["UserRole"]==null) {
- var identity = new GenericIdentity(string.Empty, string.Empty);
- httpContext.User = new GenericPrincipal(identity, new string[] { });
- FormsAuthentication.SignOut();
- Session.Clear();
- }
- else if ( session["UserRole"] != null)
- switch ((UserRoles)session["UserRole"])
- {
- case UserRoles.Adminstrator:
- httpContext.User = new GenericPrincipal(httpContext.User.Identity, new[] {"Administrator"});
- break;
- case UserRoles.Customer:
- httpContext.User = new GenericPrincipal(httpContext.User.Identity, new[] {"Customer"});
- break;
- case UserRoles.Client:
- httpContext.User = new GenericPrincipal(httpContext.User.Identity, new[] {"Client"});
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment