Solved

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

Posted on 2004-08-31
2
1,571 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select2 jquery help 9 100
Bypass cross origin issues on development site 3 95
Recordset containing single quotes 8 49
ASP Classic, check if Querystring is UCase or LCase 8 29
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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