Maintain url after login [Resolved]

Posted by Nishithraj under Regular Expressions on 2/22/2010 | Views : 2911 | Status : [Member] | Replies : 5
How do we maintain the url after login in to the website.

For example, If we have a url http://www.dotnetfunda.com/post/postquestions.aspx, and we can't post questions without logged in. so, it should be redirected to a login page. After logging, user should be redirected to the same url.

I know we can do this by passing url as a query string and redirecting to the same url again. But I don't think this is the right way of doing it. Can you provide any other methods??

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan



Responses

Posted by: Abhijit Jana on: 2/22/2010 [Member] [MVP] Bronze

Up
0
Down

Resolved
You can use
Request.UrlReferrer


When you will redirect to login page, Request.UrlReferrer will give you the last reference page. So after logged in again, you can easily redirect to the page.

Hope this is clears to you. Please let me know if you have any concern.

Cheers !
Abhijit

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/22/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Nishithraj

Most of the Time we have usercontrols on the page and panels. lets say you a page that will allow you to post and you are not logged in. The First thing that will be checked there is the session of your username, if its null then you will be redirected to the login page or the popup will come up. in that case you are looking at the same page but different panels or control have been made visible and if they are not needed they are hidden. am not sure if this is clear tell me if its not.

Thank you for posting at Dotnetfunda
[Administrator]

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 2/22/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Yes Abhijit is right.

Request.UrlReferrer will be useful. Other than that, you can also use

http:dotnetfunda.com/login.aspx?returl=http://www.dotnetfunda.com/post/postquestions.aspx

I mean pass the whole url in querystring, if you have more than one step of login. Just pass the returl with your querystring.

www.abhisheksur.com

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/24/2010 [Member] Bronze

Up
0
Down
Thanks Abhijit Jana for providing exact resolution

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhijit Jana on: 2/24/2010 [Member] [MVP] Bronze

Up
0
Down
Thanks Nishithraj. Let me know if you need any more help !!

Cheers !
Abhijit

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response