Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 4-Feb-13 18:14pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Member 9579525 at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 751
1 George Jonsson 330
2 Garth J Lancaster 290
3 Sergey Alexandrovich Kryukov 274
4 BillWoodruff 252
0 Sergey Alexandrovich Kryukov 10,879
1 OriginalGriff 5,555
2 Maciej Los 5,534
3 CPallini 3,819
4 BillWoodruff 3,594


Advertise | Privacy | Mobile
Web04 | 2.8.141030.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100