标签:
private DataDbContext db = new DataDbContext();
/// <summary>
/// 控制器执行前判断
/// </summary>
/// <param name="filterContext"></param>
void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext)
{
RedirectResult result = new RedirectResult("/USER/Login?Login=lg");
#region Sesion 值为空返回登录页面 或 登录是否超时
if (filterContext.HttpContext.Session["timeout"] == null || filterContext.HttpContext.Session["GG"] == null || filterContext.HttpContext.Session["USER"] == null)
{
// filterContext.HttpContext.Response.Redirect(result.Url);
// filterContext.Result = result;
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { Controller = "USER", Action = "Login" }));//这里是跳转到Account下的LogOff,自己定义
}
else
{
TimeSpan t = DateTime.Now - (DateTime)filterContext.HttpContext.Session["timeout"];
if (t.Minutes >= ST.timeoutmin)
{
filterContext.Result = result;
//filterContext.HttpContext.Response.Redirect("/USER/Login?Login=lg");
}
else
{
filterContext.HttpContext.Session["timeout"] = DateTime.Now;
}
}
#endregion
标签:
原文地址:http://www.cnblogs.com/louby/p/5030730.html