码迷,mamicode.com
首页 > 其他好文 > 详细

在Filter 无法跳转地址

时间:2015-12-08 20:28:33      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

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

在Filter 无法跳转地址

标签:

原文地址:http://www.cnblogs.com/louby/p/5030730.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!