我有一个文件代理IHttpHandler
来确保身份验证和记录请求。它在开发服务器和 IIS 6 上运行良好。在 IIS 7 中,我有两个问题:
Microsoft Office(Word、Excel...)使用
OPTION
和PROPFIND
动词发送 WebDAV 请求。ASP.NET 引发异常,因为它不支持它们。有没有办法在 IIS 级别禁用这些动词,使其永远不会到达 ASP.NET?我猜它会返回一个405 Method Not Allowed
错误(http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error)。IIS 7 开启分块编码。在这种情况下,
Content-Length
标头无效,显然 IIS 7 将其删除:http: //greenbytes.de/tech/webdav/rfc2616.html#rfc.section.4.4。但是,它也会删除Content-Type
标题,导致文件在浏览器中显示为文本。那么如何阻止 IIS 7 删除Content-Type
,或者如何关闭这一页的分块编码?以下是供您比较的响应标头。
开发服务器响应:
HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Thu, 23 Dec 2010 17:57:09 GMT
X-AspNet-Version: 2.0.50727
Content-Length: 68096
Content-Disposition: inline; filename=test.doc
Cache-Control: private
Last-Modified: Thu, 23 Dec 2010 09:14:18 GMT
Content-Type: application/msword
Connection: Close
IIS 7 响应:
HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Last-Modified: Thu, 23 Dec 2010 09:30:31 GMT
Server: Microsoft-IIS/7.5
Content-Disposition: inline; filename=test.doc
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Thu, 23 Dec 2010 17:57:59 GMT