由于mvc内部跳转机制的问题,它只在当前的action所渲染的view上进行跳转,如果希望在当前页面跳,需要将mvc方法改为js方法:
filterContext.Result = new RedirectToRouteResult("Default", new RouteValueDictionary {
{ "Action",_failActionName },
{ "Controller", _failControllerName},
{ "returnUrl", returnUrl} });
修改成Js方法跳转:
string url = new UrlHelper(filterContext.RequestContext).Action(
_failActionName,
_failControllerName,
new
{
returnUrl = returnUrl
});
//防止出现登陆超时,在局部跳转URL的问题
filterContext.HttpContext.Response.Write("<script>location.href='" + url + "'</script>");
filterContext.HttpContext.Response.End();