BaseController中写了如下代码 public class RedirectingActionAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext context)
{
base.OnActionExecuting(context);
if (context.Controller.ToString() ==
"ProjectService.Web.Controllers.LoginController")
{
return;
} if ((ProjectService.Core.IdentityContextHelper.Session.CompanyID == 0 ||
ProjectService.Core.IdentityContextHelper.Session.UserID == 0))
{
if (!DomainFacade.CreateLoginLogoutService().AttemptSignIn())
{
//context.Result = new RedirectResult("/Login/LoginIndex");
System.Web.HttpContext.Current.Response.Write(
@"<script type='text/javascript'language='javascript'>
top.window.location='/Login/LoginIndex'</script>");
System.Web.HttpContext.Current.Response.End();
} }
}
}跳转执行 但是依然会执行某Index页面的操作。F5后才会执行跳转。mvc
{
public override void OnActionExecuting(ActionExecutingContext context)
{
base.OnActionExecuting(context);
if (context.Controller.ToString() ==
"ProjectService.Web.Controllers.LoginController")
{
return;
} if ((ProjectService.Core.IdentityContextHelper.Session.CompanyID == 0 ||
ProjectService.Core.IdentityContextHelper.Session.UserID == 0))
{
if (!DomainFacade.CreateLoginLogoutService().AttemptSignIn())
{
//context.Result = new RedirectResult("/Login/LoginIndex");
System.Web.HttpContext.Current.Response.Write(
@"<script type='text/javascript'language='javascript'>
top.window.location='/Login/LoginIndex'</script>");
System.Web.HttpContext.Current.Response.End();
} }
}
}跳转执行 但是依然会执行某Index页面的操作。F5后才会执行跳转。mvc
你注释掉的代码才是正确的啊
依然会在这句代码执行过后,执行接下来的逻辑操作。
我正在处理的问题,模拟的就是缓存丢失。
session.removeAll();
baseController里面执行session校验。
问题所在->执行校验(跳转到login controller执行了loginIndex)但是未发生跳转-》依然执行接下来的请求逻辑(虽然返回的是空的json串)
f5刷新后才执行了跳转