В ASP.NET Web API 2 IHttpActionResult
предлагает большую ценность в упрощении кода контроллера, и я не хочу его использовать, но я столкнулся с проблемой.
Мне нужно установить ETag исходящего ответа, и я не могу найти какое-либо свойство, которое дает мне доступ к заголовкам ответов. В настоящий момент я использую вспомогательный метод Ok<T>(T content)
из ApiController
, который возвращает объект OkNegotiatedContentResult<T>
. Это, похоже, не имеет ничего, что позволило бы мне изменить заголовки, хотя.
Я что-то упустил или нет способа сделать это при использовании типов запасов IHttpActionResult
? Я рассматривал обработчик сообщений, но тогда мне нужно было бы выяснить, как передать ETag из действия (ETags генерируются по-разному для разных действий, поэтому это не вопрос создания универсального обработчика для всех действий).
Я бы хотел избежать использования необработанного HttpResponseMessage, но на данный момент это выглядит трудным.