Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It might be something really simple, believe it or not I coded exactly the same thing today, i think the issue might be that the content disposition doesnt tell the browser its an attachment and therefore able to be saved.</p> <pre><code> Response.AddHeader("Content-Disposition", "attachment;filename=myfile.doc"); </code></pre> <p>failing that i've included my code below as I know that works over https://</p> <pre> <code> private void ReadFile(string URL) { try { string uristring = URL; WebRequest myReq = WebRequest.Create(uristring); NetworkCredential netCredential = new NetworkCredential(ConfigurationManager.AppSettings["Username"].ToString(), ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["Domain"].ToString()); myReq.Credentials = netCredential; StringBuilder strSource = new StringBuilder(""); //get the stream of data string contentType = ""; MemoryStream ms; // Send a request to download the pdf document and then get the response using (HttpWebResponse response = (HttpWebResponse)myReq.GetResponse()) { contentType = response.ContentType; // Get the stream from the server using (Stream stream = response.GetResponseStream()) { // Use the ReadFully method from the link above: byte[] data = ReadFully(stream, response.ContentLength); // Return the memory stream. ms = new MemoryStream(data); } } Response.Clear(); Response.ContentType = contentType; Response.AddHeader("Content-Disposition", "attachment;"); // Write the memory stream containing the pdf file directly to the Response object that gets sent to the client ms.WriteTo(Response.OutputStream); } catch (Exception ex) { throw new Exception("Error in ReadFile", ex); } } </code> </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload