Application.DownloadAndOpen a pdf file via ssl not working

Answered
0
0

Hi,

I’m using to download a file from server the following code:

string fn=”abc.pdf”;

MemoryStream ms = new MemoryStream();
using (FileStream file = new FileStream(nf, FileMode.Open, FileAccess.Read)) file.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
Application.DownloadAndOpen(“_blank”, ms, fn);

 

I’m using something similar for some memory streams created directly in memory. The general idea is:

  • for excel files (xlsx) it’s working on both http and https
  • for pdf file, the pdf file is corectly opened in browser (on another tab) , but:
  • when using http I can push “download” button (from pdf viewer) and I can save pdf file (with the default name)
  • when using https I can push “download” button but it’s offering me to save default.html and not pdf. And even that, it saves nothing, without error.

 

  • You must to post comments
Best Answer
0
0

Hi Levie,

The code (similar with my own) is working and no error occur. The (strange) behavior is like following:

  1. When using normal HTTP, the pdf file is opened in another tab. I can view it, and I can push the “Save” button (pdf viewer in browser, near the print button). It propose me to save the pdf file with correct name (abc.pdf in our sample).
  2. when using HTTPS, the pdf file is opened in another tab. I can view it correctly, and I can push the “Save” button, but instead of saving the pdf file I got “download.html” and if I say “yes” it save nothing.

I attach the save dialog in both situations.

  • Luca (ITG)
    The url is not secure. I tried with localhost and the development ssl and it works fine. I don’t think ssl works with IPs. The second tab with the native viewer is not a Wisej widget.
  • You must to post comments
0
0

Hi Adrian,

What do you mean when you say it doesn’t work? What error does it throw?

Try this:

Application.DownloadAndOpen("_blank", Application.MapPath("abc.pdf"));

 

Your code was working for me like this:

string fn = Application.MapPath("abc.pdf");

MemoryStream ms = new MemoryStream();
 using (FileStream file = new FileStream(fn, FileMode.Open, FileAccess.Read)) file.CopyTo(ms);
 ms.Seek(0, SeekOrigin.Begin);
 Application.DownloadAndOpen("_blank", ms, fn);

Let me know how to help!
Best,

Levie

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.