c# - Fastest way to deliver images via asp.net -


I wonder how the fastest way to distribute images by ASP.NET is:

< Pre> // get file path string filepath = GetFilePath (); Response.TransmitFile (f);

or:

  string filepath = GetFilePath (); Context.Response.WriteFile (f);  

or

  Bitmap BMP = GetBitmap () bmp.Save (Response.OutputStream);  

or you can think about

.

You will need to test with large image files to see the visible difference, but the filtered output file will display the format file.

In either case, you should use the ASHX handler instead of the ASPX page. There is an additional overhead in the ASPX to serve the image, which is not necessary.

One more thing - set the content type on the file, or the browser can present it in the form of a binary guitar. In the case of BMP:

context.Response.ContentType = "image / bmp";


Comments