RE: 401 with Forms Authentication and Roles



Thanks for your further reply Chuck,

So your current implementation is using the "Application_EndRequest" event
and check both "IsAuthenticated" property and REsponse's StatusCode to
determine the user authorization status.

Actually, my suggestion in previous reply is to put the code logic directly
in the login page's Page_load event(since any unauthorized users are always
expected to be redirected to login page first). You can check the
"User.IsAuthenticated" and Request.QueryString["ReturnUrl"] there to
determine whether the current user is authenticated user and whether he is
redirected to login page because of access denied(rather than manually
navigate to login page).

here is a test code snippet that also works in my test application:


protected void Page_Load(object sender, EventArgs e)
{

if (Context.User.Identity.IsAuthenticated == true &&
Request.QueryString["ReturnUrl"] != null)
{
Server.Transfer("~/AccessDeniedPage.aspx");
}
...................
<<<<<<<<<<<<<<<<<<<<<<

One good point of using Login page is that it won't perform the check for
each ASP.NET request(like what Application_XX event or httpmodule does).

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.








.



Relevant Pages

  • RE: Failed admin logins
    ... Understanding that my suggestion may not always be possible - pull the plug and ... communicating with that box with the logs of when the login occurs. ... > I have a machine that is trying to log in as the domain administrator ...
    (Security-Basics)
  • A javascript problem,help!
    ... The problem is described below:(Use IE6) ... automatically.However,something perplexs me.When I login the computer ... Could ANYONE give suggestion about solving the problem?(the HTML cannot ...
    (comp.lang.javascript)
  • Re: DotNet application security integration with NT login.
    ... I have the windows forms, ... your suggestion and help will be greatly appreciated. ... >you could do the login yourself which works just as well. ... >complex and require some privileges on behalf of the user ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • windows 2000 blue screen after login
    ... login in windows 2000 sp4? ... I've tried the suggestion everyone made regarding ...
    (microsoft.public.win2000.security)
  • Security Methodology
    ... I'm going to be writing an asp.net application that certain users have ... User authorization will be ... I'm planning to use a session variable to first make sure the ... the user would be redirected to the login ...
    (microsoft.public.dotnet.framework.aspnet.security)