In ASP.NET Web API 2, the IHttpActionResult
offers a lot of value in simplifying controller code and I\'m reluctant to stop using it, but I\'ve hit a problem.
very old question. Probably other answers made sense that time but today you can simply add this line without changing or extending IHttpActionResult
. It perfectly adds header in your response. Make sure also to format into RFC 1123 standard as below. Otherwise, although Last-Modified appears in the headers, Client is not able to read it using HttpClient
.
System.Web.HttpContext.Current.Response.Headers.
Add(Microsoft.Net.Http.Headers.HeaderNames.LastModified, DBdateModified.Value.ToString("r"));