How to redirect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Q. John Chen

    How to redirect

    All,

    I am using Form Authentication with Roles.
    E.G. PageA.aspx is permitted for Role "Admin",
    and PageB.aspx is permitted for Role "Basic".

    When a user of "Basic" role try to access an "Admin" page directly,
    Login From shown and he enters his username and password.
    He is then AUTHENTICATED but stays on the Login form because
    he is not permitted to view the "Admin" pages.

    My question is: Is there a way to redirect the user to a "Not-permitted-page" ?

    Thanks

    John
  • Ken Cox [Microsoft MVP]

    #2
    Re: How to redirect

    Hi John,

    Can you add a section to the web.config to exempt the notpermitted.as px page
    from the authentication?

    <location path="notpermit ted.aspx">
    <system.web>
    <authorizatio n>
    <allow users="*"/>
    </authorization>
    </system.web>
    </location>




    "Q. John Chen" <nonospam@wowwa y.com> wrote in message
    news:8488de58.0 404161317.45de3 f92@posting.goo gle.com...[color=blue]
    > All,
    >
    > I am using Form Authentication with Roles.
    > E.G. PageA.aspx is permitted for Role "Admin",
    > and PageB.aspx is permitted for Role "Basic".
    >
    > When a user of "Basic" role try to access an "Admin" page directly,
    > Login From shown and he enters his username and password.
    > He is then AUTHENTICATED but stays on the Login form because
    > he is not permitted to view the "Admin" pages.
    >
    > My question is: Is there a way to redirect the user to a
    > "Not-permitted-page" ?
    >
    > Thanks
    >
    > John[/color]

    Comment

    • Q. John Chen

      #3
      Re: How to redirect

      Ken,

      I don't think that I made my question clear. Here is details:

      First, I have a login form. If a user failed to login. It will show
      the error right in the login form and ask for re-enter the
      identification:
      <authenticati on mode="Forms">
      <forms loginUrl="login .aspx" />
      </authentication>

      I have two page accessable to user in the roles, Admin and Basic in
      this example:
      <location path="PageA.asp x" >
      <system.web>
      <authorizatio n>
      <allow roles="Admin" />
      <deny users="*" />
      </authorization>
      </system.web>
      </location>

      <location path="PageB.asp x" >
      <system.web>
      <authorizatio n>
      <allow roles="Basic, Admin" />
      <deny users="*" />
      </authorization>
      </system.web>
      </location>

      Now, UserB (with 'Basic' role) logins first. Then he types PageA.aspx
      in address bar trying to access PageA. He is redirect to the Login
      page automatically. But what I wantd is to SHOW a kind of 401 error
      page rather than go the the login page.

      Thanks

      John

      Comment

      Working...