在Filter 无法跳转地址

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

posted @ 2015-12-08 19:40  骚年丶勿忘初心。  阅读(910)  评论(0编辑  收藏  举报