码迷,mamicode.com
首页 > 其他好文 > 详细

Filter进行session验证

时间:2014-07-11 12:24:38      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:style   cti   io   new   re   res   

解决方法:先创建一个新的控制器  随变命名  adminFilterConter   让他继承自controller控制器  在里面写方法

在执行方法之前授限执行  

protected override void OnActionExecuting(ActionExecutingContext filterContext)

        {

            if (Session["UserInfo"] == null)

            {

                Response.Redirect("/UserLogin/Index");

            }

            //base.OnActionExecuting(filterContext);

        }

 

再让需要被验证的controller继承自此控制器  即可进行验证  

   public class HomeController : AdminBaseController

    {

        //

        // GET: /Home/

 

        public ActionResult Index()

        {

            return View();

        }

 

    }

Filter进行session验证,布布扣,bubuko.com

Filter进行session验证

标签:style   cti   io   new   re   res   

原文地址:http://www.cnblogs.com/lierjie/p/3833941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!