Solved

ASP.Net - RedirectFromLoginPage alternative to default.aspx as the destination page?

Posted on 2004-08-31
2
1,559 Views
Last Modified: 2012-08-14
Hi there,
I'm having some problems with asp.net and authorization.

What I want to happen is the user is presented with the first page which is a login page.  they login fine and then have access to the rest of the site.

I have this
      <authentication mode="Forms" />
      
      <authorization>
            <deny users="?" />
      </authorization>

as part of my web config file.

and if the login is successful, this fires:
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(intUsrID.ToString, False) where intUsrId is my user id.  This sends the user to default.aspx automatically where the rest of the application works from.

This seems to work fine at home, where I can set the start page to be index.aspx BUT on the hosting server, they have default.aspx as the priority start file, so if it is present, this is the one that fires first, not index.aspx.

My question is:
Is there anyway to get the redirectfromloginpage to go to another page (rather than default.aspx).  That way I could have the login on default.aspx and if successful, send them elsewhere.

Maybe it's just my mis-understanding of the whole thing, so I good explaination may do the trick!

Alternatives would be greatly accepted as well.

If you need anything else, please let me know.

Cheers
Andrew

0
Comment
Question by:andrewh123
2 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 250 total points
ID: 11959386
andrewh123,
I think that is the one of the major problem if you using RedirectFromLoginPage method.
However, you can solve this problem by changing some logic there.
This is how i resolved the problem.
eg:

 Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Try
            If txtUserName.Text = "hhlee" And txtPassword.Text = "haha" Then
                If Request.QueryString("ReturnUrl") <> String.Empty Then
                    FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
                Else
                    FormsAuthentication.SetAuthCookie(txtUserName.Text, False)
                    Response.Redirect("Index.aspx", False) 'Your preferable start up page if user just access from Login.aspx
                End If
            Else
                lblMsg.Text = "Invalid login information."
            End If
        Catch ex As Exception
             lblMsg.Text="Invalid login information."
        End Try
    End Sub

Regards
x_com
0
 
LVL 1

Author Comment

by:andrewh123
ID: 12183402
Sorry I took so long to answer x_com - I had to go away for a bit just after I posted the question - thanks for your patience!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

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

18 Experts available now in Live!

Get 1:1 Help Now