Solved

RedirectFromLoginPage refuses to work!

Posted on 2004-08-31
9
237 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:ravl
ID: 11951508
Yes - as I described the root web.config has <authentication mode="Forms">
0
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

713 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