whosrdaddy
Vendor
I have a MVC website that uses FormsAuthentication.
To set the Thread.currentprincipal I use the PostAuthenticationRequest in Global.Asax:
the problem I have is that this event is fired for each request, also static files like javascript and css.
GetAuthenticatedUser uses NHibernate and poses a performance hit when I have a page with many static file requests.
How can I prevent this?
I "hacked" around this problem ATM by adding these lines to the event:
but I don't like this at all.
/Daddy
-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
To set the Thread.currentprincipal I use the PostAuthenticationRequest in Global.Asax:
Code:
protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
{
var currentPrincipal = HttpContext.Current.User;
if (currentPrincipal != null && currentPrincipal.Identity != null && currentPrincipal.Identity.IsAuthenticated)
{
Log.Debug("PostAuthenticateRequest");
var authenticationService = ServiceLocator.Current.GetInstance<IAuthenticationService>();
var userContext = ServiceLocator.Current.GetInstance<IUserContext>();
var user = authenticationService.GetAuthenticatedUser(currentPrincipal);
userContext.SetUser(user);
}
}
the problem I have is that this event is fired for each request, also static files like javascript and css.
GetAuthenticatedUser uses NHibernate and poses a performance hit when I have a page with many static file requests.
How can I prevent this?
I "hacked" around this problem ATM by adding these lines to the event:
Code:
var path = Request.AppRelativeCurrentExecutionFilePath;
if (path.ToUpper().StartsWith("~/CONTENT/") || path.ToUpper().StartsWith("~/SCRIPTS/"))
return;
but I don't like this at all.
/Daddy
-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!