N
Nieko Punt
I implemented forms based authentication in my web app and works great. Now i
want to add role-based authorization. From info on the web I know I have to
handle the AuthenticateRequest. I have code like this:
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (!(HttpContext.Current.User == null))
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity.GetType() ==
typeof(FormsIdentity))
{
// code to add roles here
}
}
}
}
I put a breakpoint at the first if statement in order to see when the event
is fired and what the values are (during login). The event is fired several
times during a single login but HttpContext.Current.User is always null, even
if I succesfully logged in. In contrast, on the web page expressions like
User.Identity.IsAuthenticated work just fine.
What am I missing here?
want to add role-based authorization. From info on the web I know I have to
handle the AuthenticateRequest. I have code like this:
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (!(HttpContext.Current.User == null))
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity.GetType() ==
typeof(FormsIdentity))
{
// code to add roles here
}
}
}
}
I put a breakpoint at the first if statement in order to see when the event
is fired and what the values are (during login). The event is fired several
times during a single login but HttpContext.Current.User is always null, even
if I succesfully logged in. In contrast, on the web page expressions like
User.Identity.IsAuthenticated work just fine.
What am I missing here?