Reputation: 3016
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?
Upvotes: 3
Views: 3789
Reputation: 8466
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");
}
Upvotes: 4