【问题标题】:403 error when opening PDF with chrome pdf viewer使用 chrome pdf 查看器打开 PDF 时出现 403 错误
【发布时间】:2013-07-17 18:29:11
【问题描述】:

我们在 ISS 7.5 中托管 C# 3.5 网络应用程序。

PDF 文件被生成并放在某个目录中。目录列表被禁用。使用所有浏览器(IE10、FF、Opera...),我们都可以访问 PDF。

使用 Chrome 访问 URL 时,PDF 已加载...然后我们收到 403 错误。如果我们禁用 chrome 内部 pdf 查看器并告诉它使用 Adob​​e 的,它可以正常工作。

有什么问题?

【问题讨论】:

    标签: google-chrome pdf http-status-code-403


    【解决方案1】:

    问题在这里解释:http://productforums.google.com/forum/#!topic/chrome/1mSjCjabwPE

    但上述知识库无法应用,因此我们将使用一些 HttpHandler

        public void ProcessRequest(HttpContext context)
        {
            switch (context.Request.HttpMethod)
            {
                case "GET":
    
                    if (!context.User.Identity.IsAuthenticated)
                    {
                        FormsAuthentication.RedirectToLoginPage();
                        return;
                    }
    
    
                    string requestedFile = context.Server.MapPath(context.Request.FilePath);
    
                    context.Response.ContentType = "application/pdf";
                    context.Response.TransmitFile(context.Server.MapPath(context.Request.FilePath));
                    context.Response.End();
    
                    break;
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2018-07-05
      • 2013-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-04
      相关资源
      最近更新 更多