How to open report in PDF inside in current browser windows, not a new browser windows from reporting services?
SQL Server 2008 Reporting Services allow to open report in PDF with following URL access:
http://localhost:8080/reportserver?/MyReports/Report1&rs:Command=Render&rs:Format=PDF
but the PDF will be open in a new browser window. How to开发者_Go百科 set proper parameter and open it in current browser window?
Ok cool, we have something to start with. It was tricky to work out how to do this (it took a reasonable number of hours), and i'm not at liberty to give you the exact code (as it belongs to the people i wrote it for), but i can give you the method for doing it. With this method you should be able to nicely host the aspx page inside a silverlight control, although you may have to think about the physical size of your rendered report it may be a little tight on space when hosted like that.
- in your aspx page, create an HttpWebRequest, the url should point to the appropriate reports folder in the SSRS installation
- create the querystring which contains the report parameters, convert it to a byte[] using Encoding.UTF8.GetBytes(parameterString)
- write that byte array to the RequestStream of the HttpWebRequest you created
- do a request.GetResponse(), assign it's output to a new HttpWebResponse object (let's call it the ssrsResponse)
- get the response object of the current page (let's call it currentResponse)
- set the content type of currentResponse to Application/PDF
- add the
Content-Disposition
header to currentResponse, set its value toinline;filename=[insert filename here]
- read the response stream from ssrsResponse and write it to currentResponse (this is just an exercise in transferring the contents of one stream to another)
- call
currentResponse.End()
精彩评论