Solved

Redirecting to a certain page using C#

Posted on 2014-11-05
5
77 Views
Last Modified: 2015-02-20
I am looking for a way for a user to login to a certain page upon login.  Let me paint a scenario.  Let's say the user wants to go to a certain page on the site, but is not able to until they login, the desired function would be to allow the user to go to the page they selected before they logged in as opposed to the default page.  How can I do that using C# with asp.net?
0
Comment
Question by:VBBRett
[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
5 Comments
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 167 total points
ID: 40423740
One way to do this is to keep the redirect location in a database table for each user:

Username     RedirectPage
VBBRett         /pages/page01.aspx
Dan7el           /pages/page05.aspx

Open in new window


Then, when the user logs in, read the page they're supposed to go to from the table and redirect to that page.
0
 

Author Comment

by:VBBRett
ID: 40424418
This is not exactly what I was anticipating.  What I mean by my question is the following:

VBBrett typically redirects to members/home.aspx when he logs in, but he thinks to type in members/controlpanel.aspx before he is able to login, so he is immediately faced with the login screen.  After he successfully puts his credentials in, I want him to be redirected to members/controlpanel.aspx since that is where he initially wanted to go before he logged in as opposed to members/home.aspx.  But, if he decides to just go through the default process, he will just be redirected to members/home.aspx.  Does that make sense?  Let me know!  Thanks!
0
 
LVL 11

Assisted Solution

by:louisfr
louisfr earned 167 total points
ID: 40425636
Are you using a Login control?
If so, do not specify a value for the DestinationPageUrl property.

If you're using a FormsAuthentication, there is a GetRedirectUrl method.

You can also look for a ReturnUrl parameter in the query.
0
 
LVL 15

Assisted Solution

by:gladxml
gladxml earned 166 total points
ID: 40427912
If you are not using login control or form authentication

You can mimic the GetRedirectURL process

Basically the previous page before it is redirected to the login has been added as a querystring. you need to code in your method where you check if the person is login or not.

Now if the person credential is correct then you can redirect that person to the previous page which can be taken in the querystring.

If somehow the person go directly to the login page therefore there is no querystring you can redirect him to the default page.

HTH.
0
 

Author Comment

by:VBBRett
ID: 40511235
OK, I am about to try it now with some C# code and will post back what the  result is.  Thank you!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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.

690 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