Redirect back to last page

If a user goes to the page demos.aspx, but they are not logged in, they are sent to the login.aspx page.  Once they have logged in, I want to sent them back to the page they were at.
Is there some function build into .NET that will do this?
rrhandle8Asked:
Who is Participating?
 
Ramkisan JagtapConnect With a Mentor Lead DeveloperCommented:
This is what I have suggested!!! You can read my comments again :)

Regards,
Ramkisan
0
 
Daniel Van Der WerkenIndependent ConsultantCommented:
I think this solution will work for what you're looking to do:
http://geekswithblogs.net/ranganh/archive/2005/04/25/37612.aspx

Here is the information on RedirectFromLoginPage():
http://msdn.microsoft.com/en-us/library/1f5z1yty.aspx
0
 
rrhandle8Author Commented:
Dan7el,

The code you sent me to at geekswighblogs makes me suspicious.  Why would I need to username?  Maybe I should state that I am not using .NET membership and roles.  This is a custom login.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Daniel Van Der WerkenIndependent ConsultantCommented:
Are you using Forms Authentication?  You can use custom memberships and roles with forms auth.
0
 
rrhandle8Author Commented:
I am not using memberships and roles.  Client insisted I not use them.  So this is all custom programming for the login.
0
 
rrhandle8Author Commented:
Couldn't this be done with something like Request.ServerVariables("HTTP_REFERER")
0
 
Ramkisan JagtapLead DeveloperCommented:
Hi
Whenever you are redirecting to the Login page, you can send the page url in QueryString then after login redirect to that page again.

Regards,
Ram
0
 
rrhandle8Author Commented:
ramkisan, There are a lot of pages.  That means I would have to update all of them.
0
 
Ramkisan JagtapLead DeveloperCommented:
You can only check in Master page for Authentication and tyen redirect from the Master page only!!

Regards,
Ramkisan
0
 
rrhandle8Author Commented:
Here is the answer.  I found it on another site.

            Dim fromURL As String = Request.ServerVariables("url")
            Response.Redirect("~/FT_Login.aspx?FromURL=" & fromURL)
0
 
rrhandle8Author Commented:
ramkisan:
OK, if you say so.  What I was look for was the Request.ServerVariables("url") statement.
0
 
rrhandle8Author Commented:
Should have been clearer in his explanation.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.