zoukankan      html  css  js  c++  java
  • 2016年5月12日我的第一个播客

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Web;
     5 using System.Web.Mvc;
     6 
     7 namespace lizhugz.Areas.lizhuAdmin.Models
     8 {
     9     public class FilterAttribute:ActionFilterAttribute
    10     {
    11         /* Filter
    12          * 体验AOP编程思想
    13          Result:视图
    14          Ation:方法
    15          用[FilterAttribute]调用
    16          放在控制器前:该控制器下所有方法经过这个验证
    17          放在方法前:该方法使用这个验证
    18          */
    19          public string Message { get; set; }
    20 
    21         //在Action执行之后执行
    22         public override void OnActionExecuted(ActionExecutedContext filterContext)
    23         {
    24            
    25             base.OnActionExecuted(filterContext);   
    26         }
    27 
    28         //在Action执行之前执行
    29         public override void OnActionExecuting(ActionExecutingContext filterContext)
    30         {
    31             if (HttpContext.Current.Session["userId"]==null)
    32             {
    33                 
    34                 HttpContext.Current.Response.Redirect("/lizhuAdmin/AdeminProData/Login");
    35             }
    36             else
    37             {
    38                 HttpContext.Current.Response.Redirect("/lizhuAdmin/AdeminProData/Index");
    39             }
    40            
    41                 
    42                 base.OnActionExecuting(filterContext);
    43           
    44             
    45         }
    46 
    47         //在Result执行之后执行
    48         public override void OnResultExecuted(ResultExecutedContext filterContext)
    49         {
    50             base.OnResultExecuted(filterContext);
    51         }
    52 
    53         //在Result执行之前
    54         public override void OnResultExecuting(ResultExecutingContext filterContext)
    55         {
    56             base.OnResultExecuting(filterContext);  
    57         }
    58     }
    59 
    60 
    61     
    62 }
    View Code
  • 相关阅读:
    HDU 5492 Find a path
    codeforce gym 100548H The Problem to Make You Happy
    Topcoder SRM 144 Lottery
    codeforce 165E Compatible Numbers
    codeforce gym 100307H Hack Protection
    区间DP总结
    UESTC 1321 柱爷的恋爱 (区间DP)
    HDU 4283 You Are the One (区间DP)
    HDU 2476 String painter (区间DP)
    UESTC 426 Food Delivery (区间DP)
  • 原文地址:https://www.cnblogs.com/ncellit/p/5486896.html
Copyright © 2011-2022 走看看