标签:idt ssi 一个 strong 类型 red contex session log
MVC支持的过滤器类型有四种,分别是:Authorization(授权),Action(行为),Result(结果)和Exception(异常)
授权过滤器的使用
新建一个类LoginAuthorityAttribute
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace ERPMVC { public class LoginAuthorityAttribute:AuthorizeAttribute { public override void OnAuthorization(AuthorizationContext filterContext) { if (filterContext.HttpContext.Session["Id"] == null) { filterContext.HttpContext.Response.Redirect("/UI/Login"); } } } }
在需要使用过滤器的控制器namespace下面添加[LoginAuthority]
标签:idt ssi 一个 strong 类型 red contex session log
原文地址:https://www.cnblogs.com/dujian123/p/10647872.html