How can I add a HTTP header to all action calls in ASP.NET MVC. Looking at the IActionFilter but could I interact with the HttpRequestMessage instance if I was to use it?
In your IActionFilter, you provide the OnActionExecuted method where you could do something like this:
void OnActionExecuted(ActionExecutedContext filterContext)
{
filterContext.HttpContext.Response.Headers.Add("Header-Name", "HeaderValue");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With