Bug in ASP.NET 2.0 response.transmitFile when you try to send a file larger then 2gig

There is a bug in the response.transtmitfile method in Whidbey that I hit the other day. It hits when you attempt to send a file larger then an int32 in size (which is about 2gig. )

You will get a ArgumentOutOfRangeException exception. "The size parameter must be between zero and the maximum Int32 value."

There is a bug filed on it and will be fixed soon (we hope). The work around we are doing for now is splitting the files into smaller chucks.

The issue is because the size parameter is a Long (Int64) and the size checking in the function is to a Int32. Minor little typo :)

 

The full stack trace from my hit of this issue is:

[ArgumentOutOfRangeException: The size parameter must be between zero and the maximum Int32 value.
Parameter name: size
Actual value was 2691338240.]
System.Web.HttpFileResponseElement..ctor(String filename, Int64 offset, Int64 size, Boolean isImpersonating, Boolean useTransmitFile) +181
System.Web.HttpWriter.TransmitFile(String filename, Int64 size, Boolean isImpersonating) +77
System.Web.HttpResponse.TransmitFile(String filename) +302
_Default.Page_Load(Object sender, EventArgs e) +22
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3743