Exemple #1
0
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            var throttleFilter = new ThrottlingFilter
            {
                Policy = new ThrottlePolicy(perSecond: 1, perMinute: 10, perHour: 60 * 10, perDay: 600 * 10)
                {
                    IpThrottling = true
                },
                Repository = new CacheRepository()
            };

            filters.Add(new HandleErrorAttribute());
        }
Exemple #2
0
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            var throttleFilter = new ThrottlingFilter
            {
                Policy = new ThrottlePolicy(perSecond: AppDataInit.PerSecond, perMinute: AppDataInit.PerMinute, perHour: AppDataInit.PerHour, perDay: AppDataInit.PerDay)
                {
                    IpThrottling = true
                },
                Repository = new CacheRepository()
            };

            filters.Add(throttleFilter);
        }
Exemple #3
0
        /// <summary>
        /// Registers the global filters.
        /// </summary>
        /// <param name="filters">The filters.</param>
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());

            var throttleMVCFilter = new ThrottlingFilter
            {
                //TODO: This policy must be changed according to you.
                Policy = new ThrottlePolicy(perSecond: 1, perMinute: 10, perHour: 60 * 10, perDay: 600 * 10)
                {
                    IpThrottling         = true,
                    EndpointThrottling   = true,
                    EndpointType         = EndpointThrottlingType.ControllerAndAction,
                    StackBlockedRequests = true
                },
                Repository = new CacheRepository()
            };

            filters.Add(throttleMVCFilter);
        }