How to display a Reporting Services report as an inline PDF, in a ASP.Net and C# web page?

前端 未结 1 2030
野趣味
野趣味 2021-01-21 09:37

I need to display a preview of a report, in an ASP.Net web page (using C# server side scripts). The preview needs to be a PDF rather than HTML and displayed inline (possibly in

相关标签:
1条回答
  • 2021-01-21 10:11

    I'm doing something that is very similar. But I'm using a HttpWebRequest instead of using the service. Here's how I'm doing it. The important part is the inline before the file name in the Content-Disposition.

    It also depends on their version of Adobe Reader (we found they need 7 or upwards) and the settings they have set inside it (in case they've set it to not open PDFs inside the browser).

    HttpResponse currentResponse = HttpContext.Current.Response;
    currentResponse.Clear();
    currentResponse.ClearHeaders();
    currentResponse.ClearContent();
    
    filename = String.Format("{0}.pdf", this.ReportName);
    currentResponse.AppendHeader("Content-Disposition", String.Format("inline;filename={0}", filename));
    currentResponse.ContentType = "Application/PDF";
    
    //Copy the content of the response to the 
    //current response using BinaryWrite
    snip....
    
    currentResponse.End();
    
    0 讨论(0)
提交回复
热议问题