开发者

Response.BinaryWrite() not working in a modal popup window

I'm working on a SharePoint application where I output a开发者_如何学运维 PDF content to the browser so that the user can save the PDF. But it is working when I do a Response.Redirect() but not when I open the same page in a new popup window using SharePoint's CommonShowModalDialog().

If I redirect to http://test/pdfoutput.aspx where I've written the BinaryWrite() code it is working fine.

But if I open the page using SharePoint's Modal dialog I'm getting the page to be opened in the pop up correctly and the code is getting executed without any exceptions while debugging. But I'm not getting the save dialog.

Same page -> Response.Redirect() - works
          -> CommonShowModalDialog() - Fails

Any ideas?


As I understand the question, the problem is that you're not always getting the "Save" dialog to appear. When not doing a Response.Redirect the content is opening within the browser window.

If this is the case, you will need to add a content disposition header and mime type to the HTTP headers in the response.

Response.AppendHeader("content-disposition", "attachment; filename=\"" + filename + "\"");
Response.ContentType = "application/pdf";


Originally I was using SharePoint's CommonShowModalDialog to show the popup. It internally (in core.js) does window.open(). But the issue was with the CommonShowModalDialog and when I replace it with a simple window.open() it worked.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜