Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Highlight Search Results in Classic ASP without searching HTML 5 55
Pass through dll 2 62
Using Classic ASP inside HTML pages 2 55
Server Timeout with Loop 6 36
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

9 Experts available now in Live!

Get 1:1 Help Now