Simon Fell > Its just code > ASP.NET and "streams"

Friday, December 19, 2003

Arrrggggghhhhhhhh, It was bad enough when I found out that HttpResponse.WriteFile would load the whole file into memory before writing it to the output stream, but at least that can be fixed with a few lines of code. But now I see that the whole request also gets buffered in memory (in HttpRequest.InputStream() ) making it impossible to use ASP.NET to upload large files (or even lots of moderately sized files simultaneously). Sigh, this is pretty poor design, IMO, files can obviously be multiple times larger than available memory, the HTTP request / response is modeled as streams for a reason, don't fuck it up by trying to drop the whole thing into a byte array at some point. Perhaps if Stream.Copy existed I wouldn't keep seeing this problem (WSE 1.0 does something similar, which I'm sure KeithBa is fixing for 2.0, right Keith ?). Anyone know if this gets fixed in Whidbey ?

Update There are comments over on Drew's blog that as WSE is built on ASP.NET, that WSE can't fix the problem, however I was refering to the WSE client buffering everything, not the server (but obviosuly the server does as well). However I don't buy that the WSE team can't fix this, if Software Artisans can write a product to handle large uploads in ASP.NET, then I'm sure the WSE team can equally come up with a workaround the ASP.NET problem, til the ASP.NET team get it fixed.