Last post Jun 15, 2008 04:59 AM by OmariO
Jun 14, 2008 03:42 PM|OmariO|LINK
What is faster or scalable? And for what file sizes?
Jun 14, 2008 04:07 PM|mbanavige|LINK
TransmitFile has its own internal buffering so will not load the entire file into memory. when sending large files, this can be an important feature.
Jun 14, 2008 04:24 PM|OmariO|LINK
Does TransmitFile just send a file chunk by chunk using small buffer? if so then i can do it myself in a simple loop.
May be there is some other differences?
Jun 14, 2008 09:11 PM|gbogea|LINK
The WriteFile method does exactly what you should do yourself to send a file down to the client. It uses an internal file stream to access the content, reads the content in a single shot, and then writes it out to the output stream. In addition, the
WriteFile method exposes a simple programming interface where all that you have to do is indicating the name of the file to download. To be precise,
WriteFile has a number of overloads and may accept additional parameters, but this doesn't change the basic fact: the method writes out a server file.
Both WriteFile and BinaryWrite methods seem perfect for streaming data down to the client. However, both can put the Web server memory under pressure if called to work on very large files. Why? It's because both methods load the entire data
block (the contents of the file or the byte array) into the Web server's memory. For large files, this can cause severe problems that can culminate in the recycling of the ASP.NET process. The
TransmitFile method is designed to elegantly work around the problem. It sends output directly from a file to the ASP.NET ISAPI extension and then down to the client, without passing a humongous string to the ISAPI extension.
The TransmitFile method was introduced years ago through a hot-fix package for ASP.NET 1.x as documented in Microsoft KnowledgeBase article KB823409 and later incorporated in the .NET Framework 1.x SP1 and newer versions of ASP.NET. In summary,
TransmitFile is the most stable and reliable of the other methods, although you won't notice any significant difference for most files.
Jun 15, 2008 04:59 AM|OmariO|LINK
Thanks to all. Now i understand.