我有一个文件代理IHttpHandler
以确保身份验证和记录请求。它工作正常,在开发服务器上和IIS 6在IIS 7,我有两个问题:IIS 7中的文件代理处理程序
微软办公软件(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
尝试```StaticFileHandler```而不是``DefaultHttpHandler``` – 2013-03-14 17:02:23