Failed network error while downloading the files from Google Chrome

12,129

Google Chrome will not open a "file save" window for you if "application/octet-stream" is your response from a form.

The content-type should be whatever it is known to be, if you know it. E.g. "application/pdf", "image/png" or whatever. See Complete list of MIME types

See this question What could keep Chrome from downloading files? for more information.

Share:
12,129
Triandh Velchuri
Author by

Triandh Velchuri

Updated on June 13, 2022

Comments

  • Triandh Velchuri
    Triandh Velchuri almost 2 years

    I written the below c# code for downloading the attachments in my application, when i run the code i can download the files using Mozilla, internet explorer but this is not working in Google Chrome.

    string base64FileString = result;
    byte[] binaryFile = Convert.FromBase64String(base64FileString);
    Response.ContentType = "application/octet-stream";
    Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", Request.QueryString["FILENAME"]));
    Response.Clear();
    Response.BufferOutput = false;
    Response.ClearContent();
    Response.BinaryWrite(binaryFile);
    Response.Flush();
    Response.Close();
    

    Can anyone please help me what changes need to do for downloading in Chrome

  • John Wu
    John Wu over 7 years
  • Triandh Velchuri
    Triandh Velchuri over 7 years
    I used "application/pdf" but still i am getting the same error.
  • Triandh Velchuri
    Triandh Velchuri over 7 years
    when i was downgraded my google chrome to older version then the above code is working fine.Is anyone know what changes we need to do for the above code for downloading the file in newer versions of Google Chrome.
  • Matt
    Matt over 6 years
    Remove Response.Close(); See stackoverflow.com/a/736462/481207
  • Jon
    Jon about 2 years
    I still get 'Failed Network error' Any ideas? thx