asp.net判定session超時跳回登錄頁,並把當前錯誤頁保存,登錄成功後跳回錯誤頁。
//判定session是否過時 public static void IsSessionOut() { if (HttpContext.Current.Session["userId"] != null || HttpContext.Current.Session["userId"].ToString().Trim() == "") { HttpContext.Current.Session["errorFile"] = HttpContext.Current.Request.Url.ToString().Trim(); HttpContext.Current.Response.Write("<mce:script language='javascript'><!-- alert('對不起,登錄超時,請重新登錄!');top.location.replace('/Login.aspx'); // --></mce:script>"); HttpContext.Current.Response.End(); } }