[AttributeUsage(AttributeTargets.Method)]
public class AuthorizeAttribute : ActionFilterAttribute
{
/// <summary>
/// 功能項目
/// </summary>
public FunctionEnum Function { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
將要做的事情寫在這邊
base.OnActionExecuting(filterContext);
}
}
套用方式
MVC controller
[FunctionAuthorize(Function = FunctionEnum.Bank)]
public ActionResult Bank()
{
return this.View();
}
attribute後面帶進去的就是 field