IIS 7.5 404 .PDF文件错误

时间:2012-11-16 02:15:57

标签: c# iis redirect iis-7.5 sitecore

我遇到了一个问题,我正在使用IIS 7.5重定向.pdf扩展URL。以下是奇怪的事情:当我的URL中不包含.pdf时,如http://mySite/documents/forms/test,pdf(test.pdf)完全打开。但是,当我这样开放时:http://mySite/documents/forms/test.pdf它正在向我展示

HTTP Error 404.0 - Not Found

您要查找的资源已被删除,名称已更改或暂时不可用。

我浏览了几个链接,例如:http://chentiangemalc.wordpress.com/2012/02/16/case-of-the-disappearing-pdf/

http://support.microsoft.com/kb/979543

但不知道它们是否合适。还尝试通过fiddler进行调试,如上所述:http://chentiangemalc.wordpress.com/2012/02/16/case-of-the-disappearing-pdf/

当我保存响应正文时,pdf文件无法以正确的格式保存。所以我猜猜有某种文件损坏?也许?但是当我没有在URL中包含.pdf时,我的文件打开了。不知道发生了什么:\

1 个答案:

答案 0 :(得分:1)

我得到了答案。我必须更改web.config文件以允许.pdf文件在浏览器中打开:

 <preprocessRequest help="Processors should derive from Sitecore.Pipelines.PreprocessRequest.PreprocessRequestProcessor">
    <processor type="Sitecore.Pipelines.PreprocessRequest.SuppressFormValidation, Sitecore.Kernel" />
    <processor type="Sitecore.Pipelines.PreprocessRequest.NormalizeRawUrl, Sitecore.Kernel" />
    <processor type="Sitecore.Pipelines.PreprocessRequest.IIS404Handler, Sitecore.Kernel" />
    <processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
      <param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, pdf</param>
      <param desc="Blocked extensions (comma separated)">*</param>
      <param desc="Blocked extensions that stream files (comma separated)">*</param>
      <param desc="Blocked extensions that do not stream files (comma separated)" />
    </processor>
    <processor type="Sitecore.Pipelines.PreprocessRequest.StripLanguage, Sitecore.Kernel" />
  </preprocessRequest>