forms authentication redirect problem.

Discussion in 'ASP .Net Security' started by Donkey, Feb 19, 2006.

  1. Donkey

    Donkey Guest

    Hi i've made a loginpage and a protected one. If the user tries to
    enter the protected page he gets redirected to the loginpage and at
    this point everything works fine.

    But when the user goes directly to the loginpage and types his pasword
    it fails to login.

    it tried to solve this with following code but this doesn't work
    properly

    if(Request.Querystring ("ReturnUrl")= "" ) then
    Response.redirect("reservatie.aspx")
    lblResult.Text = "juist maar niet ingelogd"
    else
    FormsAuthentication.RedirectFromLoginPage (TextBox1.Text, True)
    end if

    Anyone an idea what i have to change to get this to work.

    Thanks
     
    Donkey, Feb 19, 2006
    #1
    1. Advertising

  2. Hi,

    RedirectToLoginPage looks for the returnUrl query parameter. If none is there
    you have to do the redirect on your own

    a) You should check for null not "" on the query string
    b) use FormsAuthentication.SetAuthCookie and do the redirect manually to
    decouple what Rtlp does

    ---------------------------------------
    Dominick Baier - DevelopMentor
    http://www.leastprivilege.com

    > Hi i've made a loginpage and a protected one. If the user tries to
    > enter the protected page he gets redirected to the loginpage and at
    > this point everything works fine.
    >
    > But when the user goes directly to the loginpage and types his pasword
    > it fails to login.
    >
    > it tried to solve this with following code but this doesn't work
    > properly
    >
    > if(Request.Querystring ("ReturnUrl")= "" ) then
    > Response.redirect("reservatie.aspx")
    > lblResult.Text = "juist maar niet ingelogd"
    > else
    > FormsAuthentication.RedirectFromLoginPage (TextBox1.Text, True)
    > end if
    > Anyone an idea what i have to change to get this to work.
    >
    > Thanks
    >
     
    Dominick Baier [DevelopMentor], Feb 19, 2006
    #2
    1. Advertising

  3. Donkey

    Donkey Guest

    thanks for the quick respons.
    changed it to following code and now is everything working

    FormsAuthentication.SetAuthCookie(TextBox1.Text,false)
    Response.Redirect("reservatie.aspx")
     
    Donkey, Feb 19, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    2
    Views:
    1,497
    Tommy
    Feb 13, 2004
  2. Guest
    Replies:
    4
    Views:
    360
  3. Eric
    Replies:
    2
    Views:
    558
  4. Janette

    forms authentication redirect problem

    Janette, Jul 13, 2006, in forum: ASP .Net Security
    Replies:
    3
    Views:
    198
    Janette
    Jul 14, 2006
  5. Sal
    Replies:
    1
    Views:
    549
Loading...

Share This Page