Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

RedirectFromLoginPage refuses to work!

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
ravl
Asked:
ravl
  • 4
  • 3
1 Solution
 
AerosSagaCommented:
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
 
ravlAuthor Commented:
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
 
AerosSagaCommented:
did you set your web.config for forms authentication?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ravlAuthor Commented:
Yes - as I described the root web.config has <authentication mode="Forms">
0
 
AerosSagaCommented:
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
 
ravlAuthor Commented:
AerosSaga - if you read the detail I provided you will see that I have indeed done this.
0
 
ravlAuthor Commented:
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
 
moduloCommented:
Closed, 125 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now