2

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?

NLV
  • 21,141
  • 40
  • 118
  • 183
  • See http://stackoverflow.com/questions/104601/asp-net-response-redirect-to-new-window – dhirschl Mar 14 '11 at 12:28
  • Would you consider altering the question to reflect the detail revealed in your accepted answer? i.e. that the issue was found when using SharePoint's CommonShowModalDialog. Otherwise this question looks like the one dhirschl refers to. – Josh Gallagher Apr 28 '11 at 22:02

2 Answers2

0

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";
Josh Gallagher
  • 5,211
  • 2
  • 33
  • 60
0

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.

NLV
  • 21,141
  • 40
  • 118
  • 183