Solved

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

Posted on 2004-08-31
2
1,569 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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