Solved

RedirectFromLoginPage refuses to work!

Posted on 2004-08-31
9
233 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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