Skip to content

Instantly share code, notes, and snippets.

@ArnisL
Created October 19, 2010 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArnisL/634190 to your computer and use it in GitHub Desktop.
Save ArnisL/634190 to your computer and use it in GitHub Desktop.
globalasax.cs
namespace Interreg.Web{
using System;
using System.Security.Principal;
using System.Web.Security;
using MvcExtensions.StructureMap;
public class MvcApplication:StructureMapMvcApplication{
//ignore this bullshit code...
protected void Application_AuthenticateRequest(Object sender,EventArgs e){
var authCookie=Context.Request.Cookies[FormsAuthentication.FormsCookieName];
if(authCookie==null||authCookie.Value=="") return;
var authTicket=FormsAuthentication.Decrypt(authCookie.Value);
var roles=authTicket.UserData.Split(new[] {','});
if(Context.User!=null) Context.User=new GenericPrincipal(Context.User.Identity,roles);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment