Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am redirecting user from one page to login page...but on login page if user directly do login then he will be redirecting to profile page and if he redirects from different page then he should be redirecting to different than profile..I have done using ReturnUrl query string parameters but i am getting exception when i directly login..Becoz it dont gets ReturnUrl of ...so what shoud i do?
Posted

1 solution

you have implement your own logic. If user directly goes to login page then you can easily redirect to the page where you want because you know where to redirect ie what is the first page after login.

So Have a check on returnurl if you have returnurl then redirect to returnurl else redirect to first page after login
 
Share this answer
 
Comments
Member 9579525 5-Feb-13 0:44am    
thank u....i have tried that but getting exception "Object reference not set to an instance of an object."

//my code


string retrnurl = Request.QueryString["ReturnUrl"].ToString();//exception
if (!string.IsNullOrEmpty(retrnurl))
{

}
else
{

}
Brij 5-Feb-13 1:31am    
You code is wrong. Request.QueryString["ReturnUrl"] would return null if it is not there and you cannot use ToString() on null objects. So have a check like
if (Request.QueryString["ReturnUrl"] != null)
{
string retrnurl = Request.QueryString["ReturnUrl"].ToString();
}
else
{

}
Member 9579525 5-Feb-13 2:19am    
now its working...Thanx

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