Meeting the needs of your business from a distance

Sending Large Responses Back From ASP.NET

by Mark Shiffer 9/20/2007 6:46:00 PM

I recently ran into some issue when attempting to transmit large files as a response to an ASP.NET request. My App was set up with the following standard code:

Response.AddHeader("Content-Length", info.Length.ToString());

Response.ContentType = "application/octet-stream";

Response.AppendHeader("Content-Disposition", "attachment;filename=" + info.Name);

Response.WriteFile(path);

 It turns out that WriteFile causes the server to attempt to buffer the response, and with a large file this just makes the server sit and time out with no useful error message being returned. I first got thrown off and attempted to increase buffer limits in IIS (defaulted to 4MB), but that did not help the issue. I then found Response.TransmitFile which does not buffer the response. So far, Response.TransmitFile appears to have fixed the issue. The files in question were 75MB to 100MB a piece. I had tested and 20MB files were able to make it through with the original code (odd with IIS's default limit being 4MB). So, I am not certain where the cutoff is, and what, if any, setting would allow Response.WriteFile to function for larger files.

Another odd part about this error was that when running locally in debug mode in VS, I had no problems. The file was still located on a network server. However, when the application was run from the server the error occurred.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Issues

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag





Live preview

July 9. 2008 00:26

About the author

Name of author Mark Shiffer
CEO & CIO of MS Consulting

E-mail me Send mail

Calendar

<<  July 2008  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

Pages

    Recent posts

    Recent comments

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in

    Copyright © 2001-2008 MS Consulting, Inc. All Rights Reserved.