Key place, in the OnActionExecuting function, you cannot use the FilterContext.HttpContext.Response.Redirect (URL) to orient, the break point can be found as executing the action inside the code. Filtercontext.result should be set to control steering.
1 stringRETURNURL =HttpContext.Current.Request.Url.PathAndQuery;2 varurl = formsauthentication.loginurl +"? returnurl="+Httputility.urlencode (RETURNURL);3 //HttpContext.Current.Response.Redirect (URL, true);//Enter Action4 //filterContext.HttpContext.Response.Redirect (URL);//Enter Action5 /*Filtercontext.result = new Redirecttorouteresult (//Do not enter action6 New RouteValueDictionary7 {8 {"Action", "Login"},9 {"Controller", "Admin"},Ten {"ReturnUrl", RETURNURL} One });*/ AFiltercontext.result =NewRedirectresult (URL);//without entering action, go to the login page.
C # MVC4 executes an attribute and then no longer executes the action