First, inherit the Checklogincontroller class on the controller to check the login
2, the Checklogincontroller class of the wording
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;namespacetaskmanagement.controllers{ Public classChecklogincontroller:controller {/// <summary> ///Implementing a unified login validation check/// </summary> /// <param name= "Filtercontext" ></param> protected Override voidonactionexecuting (ActionExecutingContext filtercontext) {//if the session value is not set then jump to the login page//Implementing a login Check if(session["UserInfo"] ==NULL) { //Redirectresult tourl = new Redirectresult ("/login/userlogin"); //filtercontext.result = Tourl;Contentresult Cr =NewContentresult {Content=string. Format ("<script type= ' text/javascript ' >top.location.href= ' {0} ';</script>","/login/userlogin") }; Filtercontext.result=Cr; } } }}
ASP. NET MVC Session expiration verification jump to login page