Failed network error while downloading the files from Google Chrome

ⅰ亾dé卋堺 提交于 2019-12-23 03:00:51

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/40003050/failed-network-error-while-downloading-the-files-from-google-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!