Thursday, 2 August 2012

Redirect to Previous Page after Login/or Timeout!

Some times, In Web app. we signout or timeout the application redirect us to Login.aspx Page. when we Login again it redirects us to Welcome/default.aspx
But, User get should redirect to that page from which he was redirected to Login.aspx due to signout or timeout.

See these Links
Simple Logic..
When User Timedout and he has to login again.. redirect User with QueryString "ReturnUrl" and Get the Url of the Page when User Timedout or Signout..
and When Login.. Check is there any QueryString or "ReturnUrl" If its null Simply redirect him to Welcome Page if its not Null then Redirect him to that Page.
Login Button Code will be like this its Example..

if (Request.QueryString["ReturnUrl"] != null)
{
Response.Redirect(Request.QueryString["ReturnUrl"].ToString());
}
else
{
Response.Redirect("WelcomePage-OR-HomePage.aspx");
}
Also see
Good Luck`

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More