【问题标题】:Asp.net Display Pdf on Chrome - Error ERR_HTTP2_PROTOCOL_ERRORAsp.net 在 Chrome 上显示 Pdf - 错误 ERR_HTTP2_PROTOCOL_ERROR
【发布时间】:2021-02-04 20:19:21
【问题描述】:

我想让用户显示一个 pdf 并将其保存在我的 asp.net 项目中。

我的代码如下:

string yol = e.CommandArgument.ToString();
            string path = Server.MapPath("~/Raporlar/2021/" + yol.Trim());

            WebClient User = new WebClient();
            Byte[] s = User.DownloadData(path);
            System.IO.MemoryStream ms = new System.IO.MemoryStream(s);

            if (ms != null && ms.Length > 1)
            {
                Response.Clear();
                Response.ClearHeaders();
                Response.ClearContent();
                Response.Charset = "UTF-8";
                Response.Buffer = true;
                Response.AddHeader("Content-Length", ms.Length.ToString());
                Response.AddHeader("Content-Disposition", "inline; filename=\"" + yol + "\"");
                Response.AddHeader("Expires", "0");
                Response.AddHeader("Pragma", "cache");
                Response.AddHeader("Cache - Control", "private");
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(ms.ToArray());
                Response.Flush();
                try { Response.End();
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                }
                catch { }
            }

显示按钮仅适用于 Firefox。其他浏览器(Google Chrome、Opera、Edge..)不显示 pdf 并给出如下错误:

嗯……此页面不可用。 https://massgrup.com/Raporlar.aspx 的网页可能遇到一些问题或已永久移动到新的网址。 ERR_HTTP2_PROTOCOL_ERROR

【问题讨论】:

    标签: asp.net google-chrome pdf http-error


    【解决方案1】:

    我解决了这个问题。这是关于ssl证书的。

    当我点击按钮时,链接是这样的:“https:https://massgrup.com/"

    因为该按钮不适用于 Chrome 浏览器。

    删除 ssl 证书后问题就解决了。

    但是现在我必须解决如何安装 ssl 证书的问题。这是另一种情况。

    【讨论】:

      猜你喜欢
      • 2011-08-05
      • 2021-08-24
      • 2012-08-11
      • 2012-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 2017-07-15
      相关资源
      最近更新 更多