相关疑难解决方法(0)

来自asp app的流式mime类型'application/pdf'在Google Chrome中失败

我有一个Web应用程序,可以在点击事件中流式传输PDF文件,它可以在IE,Firefox和Safari中正常工作,但在Chrome中它永远不会下载.下载只是读取"中断".Chrome处理流媒体有何不同?我的代码看起来像:

        this.Page.Response.Buffer = true;
        this.Page.Response.ClearHeaders();
        this.Page.Response.ClearContent();
        this.Page.Response.ContentType = "application/pdf";
        this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
        Stream input = reportStream;
        Stream output = this.Page.Response.OutputStream;
        const int Size = 4096;
        byte[] bytes = new byte[4096];
        int numBytes = input.Read(bytes, 0, Size);
        while (numBytes > 0)
        {
            output.Write(bytes, 0, numBytes);
            numBytes = input.Read(bytes, 0, Size);
        }

        reportStream.Close();
        reportStream.Dispose();
        this.Page.Response.Flush();
        this.Page.Response.Close();
Run Code Online (Sandbox Code Playgroud)

关于我可能缺少什么的任何建议?

asp.net google-chrome mime-types

2
推荐指数
1
解决办法
7438
查看次数

标签 统计

asp.net ×1

google-chrome ×1

mime-types ×1