排名
                
                
                    6
                
            
                    文章
                
                
                    6
                
            
                    粉丝
                
                
                    16
                
            
                    评论
                
                
                    8
                
            
            {{item.articleTitle}}
            
    {{item.blogName}} : {{item.content}}
        
            ICP备案  :渝ICP备18016597号-1
        
        
            网站信息:2018-2025TNBLOG.NET
        
        
            技术交流:群号656732739
        
        
            联系我们:contact@tnblog.net
        
        
            公网安备: 50010702506256
50010702506256
        
     50010702506256
50010702506256
         
        
            欢迎加群交流技术
        
     分类:
    .net mvc
    
    分类:
    .net mvc
过滤器大部分操作都需要通过filterContext点出来
         public void OnActionExecuting(ActionExecutingContext filterContext)
        {
                //获取Session的值
            var username = filterContext.HttpContext.Session["UserName"];
            var pwd = filterContext.HttpContext.Session["pwd"];
            //页面跳转(方法一)
            Controller controller = filterContext.Controller as Controller;
            if (username == null || pwd == null)
            {
             controller.HttpContext.Response.Redirect("/join/index");
            }
            //页面跳转(方法二)
            filterContext.Result = new RedirectResult("/Home/Index");
            
            //获取控制器名字
            string contextname =  filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            
            //return可以跳过验证
           
        }评价
    
 
         
        