Solved

RedirectFromLoginPage refuses to work!

Posted on 2004-08-31
9
230 Views
Last Modified: 2008-03-17
Windows XP Prof.
FormsAuthentication.RedirectFromLoginPage(txtUserID.Text, True) fails to redirect to original URL.

I have text book code as described in the MS MCAD/MCSD self paced training book. I know it works 'cos I've had it working. But now it refuses to work! Can't believe the time I've spent trying to track this down. Now it's driving me crazy! Pls can anyone see a problem?

Redirection to the login page happens OK. The user is validated OK and the cookie gets written OK but the application just stays on the login page.

root webconfig:
<authentication mode="Forms">
            <forms name="freddy" loginUrl="AdminLogin.aspx">
                  <credentials passwordFormat="SHA1">
                  </credentials>
            </forms>
</authentication>

restricted folder webconfig:
<authorization>
        <deny users="*" />
</authorization>

AdminLogin.aspx:
    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        'authenticate username/password from Users.xml
        If IsUserValid(txtUserID.Text, txtPassword.Text) Then
            FormsAuthentication.RedirectFromLoginPage(txtUserID.Text, True)
        Else
            litStatus.Text = "This userID and password is not authorised, try again."
        End If

        End If
    End Sub

0
Comment
Question by:ravl
  • 4
  • 3
9 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11948450
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        'authenticate username/password from Users.xml
        If IsUserValid(txtUserID.Text, txtPassword.Text) Then
            FormsAuthentication.RedirectFromLoginPage(txtUserID.Text, True)
            Response.Redirect("Mypage.aspx")
        Else
            litStatus.Text = "This userID and password is not authorised, try again."
        End If

        End If
    End Sub

Regards,

Aeros
0
 
LVL 1

Author Comment

by:ravl
ID: 11948485
Thanks Aeros. But the Response.Redirect makes no difference, still stuck on the login page. This also ties you to redirection to a specific page.
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11951263
did you set your web.config for forms authentication?
0
 
LVL 1

Author Comment

by:ravl
ID: 11951508
Yes - as I described the root web.config has <authentication mode="Forms">
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 17

Expert Comment

by:AerosSaga
ID: 11951560
but did you specify the loginUrl so it knows where to return?
 <authentication mode="Forms" >
    <forms name="synthesis" loginUrl="login.aspx" timeout="30" />
      </authentication>
0
 
LVL 1

Author Comment

by:ravl
ID: 11958664
AerosSaga - if you read the detail I provided you will see that I have indeed done this.
0
 
LVL 1

Author Comment

by:ravl
ID: 11979370
The trick, always obvious once someone points it out, dear friends is:

<deny users="?" /> to deny unauthenticated users in the restricted web folder's webconfig.

Eventually found an answer in one of the many web forums through someone who had the same problem.

Sorry I can't allocate any points in this case. But thanks anyway.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12048718
Closed, 125 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now