C# IE不会在浏览器中显示生成的PDF

C# IE不会在浏览器中显示生成的PDF,c#,asp.net,internet-explorer,pdf,C#,Asp.net,Internet Explorer,Pdf,我已经尝试了很多方法来让它工作,如果我使用 Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", newFileInfo.Name)); 而不是 Response.AddHeader("Content-Disposition", string.Format("inline; filename={0}", newFileInfo.Name)); 它可以工作,但我需要它显示在浏览器窗

我已经尝试了很多方法来让它工作,如果我使用

Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", newFileInfo.Name));
而不是

Response.AddHeader("Content-Disposition", string.Format("inline; filename={0}", newFileInfo.Name));
它可以工作,但我需要它显示在浏览器窗口中才能正常工作。内联视图在Chrome中正常工作。我尝试过使用Response.BinaryWrite和Response.WriteFile,但没有任何区别

我正在使用Internet Explorer 9

这是我的密码:

    Response.Clear();
    Response.ClearHeaders();
    Response.ClearContent();

    Response.Buffer = true;

    Response.ContentType = "application/pdf";
    Response.AddHeader("Pragma", "public");
    Response.AddHeader("expires", "0");
    Response.AddHeader("Cache-Control", "no-cache");
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    string filePath = Request["file"];
    string signatureFile = Request["SignatureImage"];
    double xPos = Convert.ToDouble(Request["X-Pos"]);
    double yPos = Convert.ToDouble(Request["Y-Pos"]);
    double scale = Convert.ToDouble(Request["Scale"]);

    if (!string.IsNullOrEmpty(filePath))
    {
        try
        {                
            string newFile = PDFTools.SignPDF(filePath, signatureFile, xPos, yPos, scale, tempDirectory);
            var newFileInfo = new FileInfo(newFile);
            Response.AddHeader("Content-Disposition", string.Format("inline; filename={0}", newFileInfo.Name));
            Response.AddHeader("content-length", newFileInfo.Length.ToString());

            Response.TransmitFile(newFile);
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            Debug.WriteLine("Error: " + ex.Message);
            Debug.WriteLine("at " + ex.StackTrace);
        }
        finally
        {
            Response.End();
        }
    }

谢谢你的时间

Chrome有内置的PDF浏览器,但Internet Explorer没有。您是否安装并配置了外部PDF查看器(即Adobe Acrobat或Adobe Reader)用于web视图


很抱歉,没有代表,无法发表评论。

这解决了我的问题,我安装了第三方pdf查看器,卸载了它并安装了最新的adobe reader。@kbolino,我看了很多文章,但最终你的解决方案对我有效。谢谢