Gab*_* S. 5 iis http-headers asp.net-web-api
我正在开发一个ASP.NET Web API应用程序,它使用自定义日期时间http标头响应客户端.虽然我已经阅读了几篇描述如何从ASP.NET/IIS中删除响应头的文章,但这个文章似乎总是很有弹性,我无法摆脱它.它似乎被放置在程序员/管理员控制之外的某个响应管道中,最后.
我知道不在响应中包含"Date"标头可能是一种不好的做法,但正如我所提到的,自定义日期时间标题(以刻度而不是字符串表示形式)使默认值为冗余; 此外,这是一个私有API,所以我确切地知道谁和如何使用它.
因此,可以以任何方式在IIS(v7 +)中为特定站点(或直接从Web API应用程序)中删除此标头吗?
编辑:
我尝试了(没有成功)以下技术:
<httpProtocol><customHeaders>部分中明确删除web.config中的标头protected void Application_PreSendRequestHeaders(object sender, EventArgs e)方法中的标头删除代码Global.asax.cs根据 HTTP Spec,Date 标头是强制性的,除了我认为不适用于您的情况的这些条件:
Origin servers MUST include a Date header field in all responses, except in these cases:
1. If the response status code is 100 (Continue) or 101 (Switching
Protocols), the response MAY include a Date header field, at
the server's option.
2. If the response status code conveys a server error, e.g. 500
(Internal Server Error) or 503 (Service Unavailable), and it is
inconvenient or impossible to generate a valid Date.
3. If the server does not have a clock that can provide a
reasonable approximation of the current time, its responses
MUST NOT include a Date header field. In this case, the rules
in section 14.18.1 MUST be followed.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3165 次 |
| 最近记录: |