Skip to content

Instantly share code, notes, and snippets.

@zarxor
zarxor / ThrottleAttribute.cs
Last active January 1, 2019 21:00
Request throttling for .NET Core MVC
[AttributeUsage(AttributeTargets.Method)]
public class ThrottleAttribute : ActionFilterAttribute
{
public string Name { get; set; }
public int Seconds { get; set; }
public string Message { get; set; }
private static MemoryCache Cache { get; } = new MemoryCache(new MemoryCacheOptions());
public override void OnActionExecuting(ActionExecutingContext c)