When forms authentication cookie expires, the user will be redirected to the login page (which is set in the config file). After login, you can redirect the user to the page that he/she was in before expiration according to the ReturnUrl
parameter provided by forms authentication. Using the code block below, you can also maintain the Query String of the page before expiration:
string querystring = "";
foreach (string key in Request.Params.AllKeys)
{
string value = Request.QueryString[key];
if (!string.IsNullOrEmpty(value))
querystring += "&" + key + "=" + value;
}
if (querystring.Length > 0)
querystring = Server.UrlEncode(querystring.Remove(0, 1));
Response.Redirect(FormsAuthentication.LoginUrl + "?ReturnUrl=" +
System.Web.HttpContext.Current.Request.Url.AbsolutePath + "?" + querystring);