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:
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?
This just means that chrome didn't navigate away from the page. The behavior is by design. Don't worry about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With