c# - Dispose image and memory stream objects after calling HttpContext.Response.OutputStream.Write() -
how improve code below in terms of better performance? example, must explicitly dispose both memorystream
, image
objects after calling outputstream.write()
?
any improvement on other areas, e.g. buffer
, memorystream
allocation?
the code allow web user download png file. part of below:
outputimage(image); image.dispose(); ... public void outputimage(image image){ using(memorystream temp = new memorystream()){ image.save(temp, imageformat.png) byte[] buffer = temp.getbuffer(); context.response.outputstream.write(buffer, 0, temp.length); } }
asp.net, .net 4.5
response.outputstream getbuffer
Comments
Post a Comment