Asp.net IIS 7中的文件代理处理程序

Asp.net IIS 7中的文件代理处理程序,asp.net,iis-7,content-type,chunked-encoding,Asp.net,Iis 7,Content Type,Chunked Encoding,我有一个文件代理来确保身份验证和记录请求。它在开发服务器和IIS 6上运行良好。在IIS 7中,我有两个问题: Microsoft Office(Word、Excel…)使用选项和PROPFIND动词发送WebDAV请求。ASP.NET抛出异常,因为它不支持它们。有没有办法在IIS级别禁用这些谓词,使其永远不会到达ASP.NET?我猜它将返回一个405不允许的方法错误(http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Clien

我有一个文件代理来确保身份验证和记录请求。它在开发服务器和IIS 6上运行良好。在IIS 7中,我有两个问题:

  • Microsoft Office(Word、Excel…)使用
    选项和
    PROPFIND
    动词发送WebDAV请求。ASP.NET抛出异常,因为它不支持它们。有没有办法在IIS级别禁用这些谓词,使其永远不会到达ASP.NET?我猜它将返回一个
    405不允许的方法
    错误(http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error)

  • IIS 7启用分块编码。在这种情况下,
    内容长度
    标题无效,显然IIS 7会删除它:。但是,它也会删除
    内容类型
    标题,导致文件在浏览器中显示为文本。那么,如何阻止IIS 7删除
    内容类型
    ,或者如何关闭这一页的分块编码?下面是供您比较的响应标题

  • 开发服务器响应:

    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
    
    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
    
    IIS 7响应:

    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
    
    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
    

    我关于分块编码的问题是不准确的。我在我的开发机器上做了一个小改动:我添加了
    内容长度
    。在开发机器上,这并没有什么不同——它一直在工作。在iis7中,添加
    内容长度
    实际上禁用了分块编码,一切正常


    对于WebDAV请求,IIS 7不会将它们发送到ASP.NET,因此我们没有问题。但是,开发服务器会这样做。我看到有人建议添加
    DefaultHttpHandler
    来处理它们,但在开发服务器上,这意味着原始的aspx页面被提供。

    尝试使用
    StaticFileHandler
    而不是
    DefaultHttpHandler