Tag:color sys Problem solving name nbsp eva ase else rect
public class Basecontroller:controller {protected User UserInfo {set { session["UserInfo"] = value; get {if (session["UserInfo"] = = null) {return Null } else {return (User) session["UserInfo"]; }}} protected override void OnActionExecuting (ActionExecutingContext filtercontext) { Verification Code if (FilterContext.ActionDescriptor.ActionName.Equals ("Validatecode", STRINGCOMPARISON.CURRENTCU Ltureignorecase)) {return; } #region session to determine if (Userinfo==null &&!filtercontext.actiondescriptor.actionname.contain S ("Login")) {Filtercontext.result =//new redirectresult ("/home/login");//This can also New Redirecttorouteresult ( New System.Web.Routing.RouteValueDictionary {"Controller", "Home"}, {"Action", "Login"}); Response.Redirect ("/home/login");//Do not recommend this, it will continue to execute the action return; } #endregion base. OnActionExecuting (Filtercontext); } }
foreground resolves nested iframe problem (valid for ActionResult return page, invalid with Ajax request)
<script type="text/javascript" > $ (function () { //if (window! = top) { Top.location.href = Location.href;}}); </script>
For AJAX requests, using the above method, the AJAX request is unchanged, the Ajax return status code 302, and login returns the status code 200, the theory is displayed, but
MVC Ajax Access Background When session expiration cannot jump to login page problem Resolution