其他分享
首页 > 其他分享> > .NET Core TODO: ActionFilterAttribute & IOperationFilter & HandlerMiddleware

.NET Core TODO: ActionFilterAttribute & IOperationFilter & HandlerMiddleware

作者:互联网

.NET Core TODO: ActionFilterAttribute  & IOperationFilter & HandlerMiddleware

 

 

ActionFilterAttribute  

    public class MyActionFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
           //....
        }

        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
           //....
        }
    }



        //Startup.cs
        public void ConfigureServices(IServiceCollection services)
        {
           
            services.AddControllers(o => {
                o.Filters.Add(typeof(MyActionFilter));
            }).AddJsonOptions(o =>
            {
                
            });

        }

  

参考:wcf - Execute code before (EVERY) Web API action - Stack Overflow

 

标签:Core,void,....,IOperationFilter,ActionFilterAttribute,NET,public
来源: https://www.cnblogs.com/panpanwelcome/p/16497065.html