Click here to Skip to main content
16,011,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here i am developing social network application in asp.net & i am sending some recommended profiles on all users email ID.
So what i want when user click on users name then first my application will ask for login & after login user will redirect to that particular users profile.
So how to do this in asp.net
Posted
Comments
Thanks7872 25-Apr-13 3:24am    
e.g. you have sent prathmesh812 a link to connect with RohanLeuva,then store URL to rohanleuva's account,after login redirect user to that url and delete from where you stored it.

1 solution

FormsAuthentication.RedirectFromLoginPage Method (String, Boolean)

If you are using FormsAuthentication Class[^], then it will easy for you.
Just try to implement FormsAuthentication.RedirectFromLoginPage Method[^]

Atricles
1. Implementing Forms Authentication in ASP.Net[^]
2. How to: Implement Simple Forms Authentication[^]

Custom Logic

If you have not implemented the FormsAuthentication Class, then you have to use some of your own custom logic. That may be like below.

-> User requests some URL like www.example.com/MyPage.aspx.

-> You must be checking whether the user is loggedin or not by Sessions.

-> If user is loggenin, then he/she can access, else you redirect to login page with a ReturnUrl as QueryString Parameter like below.
www.example.com/login.aspx?RetutnUrl=MyPage.aspx

And you can get the Current Page/Request Page Url (MyPage.aspx) by HttpContext Class.
Refer - How to get the URL of the current page in C#[^]

-> In login page, when user is successfully loggedin, just fetch the QueryString and Redirect to that page using Response.Redirect.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900