开发者

Problem displaying PDF in IE8 via Silverlight application

I have a Silverlight 4 application from which I'm attempting to display a PDF. My approach has been to upon a button click in the Silverlight application, use HtmlPage.Window.Navigate to open a new browser window. The URL for that this new browser window navigates to is 开发者_StackOverflow社区an ASP.Net web forms page that makes a call to SQL Reporting Services via the SSRS SOAP API. This call returns a byte array which the web form then streams back to the browser with the following code:

        byte[] report = SSRSRenderReport(reportPath, primaryId);

        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("cache-control", "must-revalidate");
        Response.AddHeader("content-length", report.Length.ToString());
        Response.Buffer = true;
        Response.ContentType = "application/pdf";
        this.Response.AddHeader("Content-Disposition", "inline; filename=whatever.pdf");
        Response.BinaryWrite(report);
        Response.Flush();
        Response.End();

This all works quite well when running the application from IE9 and Firefox. However when running the application from IE8, the new browser window is displayed after the button click but then closes immediately without ever displaying the PDF or prompting to open/save the PDF.

If I take Silverlight out of the picture and just browse directly to the URL that renders the report, it works fine, the PDF is displayed in the browser. I've seen a few posts that describe this issue when HTTPS is being used, however I'm only using HTTP currently.

Any suggestions on how to get around this issue would be much appreciated.


Try this, http://www.divelements.com/silverlight/tools.aspx I used this to embed a flash site within a silverlight webpage, so as long as you are sure of the size of the pdf viewer you should be ok.


We discovered that the source of this problem was that we were attempting to display our popup window from a viewmodel rather than a view event handler. Eventually we opted to introduce a new view which contains a hyperlink pointing to the URL of the PDF. This works and was for us, an acceptable solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜