To implement global add log statistics to MVC and API interfaces, the Web API is added in a somewhat different way
FilterConfig.cs Page Public classFilterconfig { Public Static voidregisterglobalfilters (globalfiltercollection filters) {filters. ADD (NewAuthorizeattribute ()); Filters. ADD (NewHandleerrorattribute ()); } Public Static voidregisterwebapiglobalfilters (httpfiltercollection filters) {filters. ADD (NewLogapifilter ()); }}global.asax pageprotected voidApplication_Start () {arearegistration.registerallareas (); Globalconfiguration.configure (Webapiconfig.register); GLOBALFILTERS.FILTERS.ADD (NewLogmvcfilte ()); Filterconfig.registerglobalfilters (globalfilters.filters); Filterconfig.registerwebapiglobalfilters (GlobalConfiguration.Configuration.Filters); Routeconfig.registerroutes (routetable.routes); Bundleconfig.registerbundles (Bundletable.bundles); //Defining Timers_timer =NewTimer (Timercircle_callback,NULL,0, Timeout.infinite); }
Http://stackoverflow.com/questions/9521040/how-to-add-global-asp-net-web-api-filters
How-to-add-global-asp-net-web-api-filters