Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome showing "canceled" on successful file download (200 status)

Not sure if this is an actual problem or not, but I'm writing a file out in ASP.NET, and even though the file always successfully goes through, in Chrome's developer tools, network tab, I always see the line in red, marked "Canceled".

I've tried lots of ways of doing this - for simplicity, I'm trying this with a simple text file, but it's true for PDF and other file types as well.

WebForms: I've tried it with lots of combinations of the following:

Response.Clear();
// and/or/neither
Response.ClearHeaders();

// with and without this
Response.Buffer = true;

Response.Charset = "";
// or/neither
Response.Charset = "utf-8";

// application/pdf for PDF, also tried application/octet-stream
Response.ContentType = "text/plain";

// with and without this
Response.AddHeader("Content-Length", bytes.Length.ToString());

Response.AddHeader("Content-Disposition", "attachment; filename=1.txt");

// bytes is the UTF8 bytes for a string or the PDF contents
new MemoryStream(bytes).WriteTo(Response.OutputStream);
// or
Response.Write("12345");

// any combination of the following 3, or none at all
Response.Flush();
Response.Close();
Response.End();

MVC (2 and 3, haven't tried 4):

byte[] fileContents = Encoding.UTF8.GetBytes("12345");
return File(fileContents, "text/plain", "1.txt");
// or
return File(@"C:\temp\1.txt", "text/plain", "1.txt");

It's always the same - the file goes through just fine, but dev tools shows me this: dev tools network output

I'm thinking of just ignoring it and moving on with life, but the red just bothers me. Any idea how I can deal with that?

like image 803
Joe Enos Avatar asked Mar 13 '13 18:03

Joe Enos


1 Answers

This just means that chrome didn't navigate away from the page. The behavior is by design. Don't worry about it.

like image 59
Dan Avatar answered Oct 22 '22 18:10

Dan