我使用下面的代码来限制我的ASP.NET Web:
public class Throttle : ActionFilterAttribute
{
public override async Task OnActionExecutingAsync(HttpActionContext context, CancellationToken cancellationToken)
{
// ...
if (throttle)
{
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Conflict));
}
}
}
但是,我不能返回错误代码429,因为它不在HttpStatusCode枚举中。有没有办法返回自定义错误代码?
https://stackoverflow.com/questions/25324851
复制相似问题