?
Solved

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

Posted on 2004-08-31
2
Medium Priority
?
1,586 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 1000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

801 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