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

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

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

    Donkey, Feb 19, 2006
    1. Advertisements

  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], Feb 19, 2006
    1. Advertisements

  3. Donkey

    Donkey Guest

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

    Donkey, Feb 19, 2006
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.