private static void WriteGifImageToResponse(HttpContext context, string resourcePath) { HttpResponse response = context.Response; response.ContentType = "image/gif"; Assembly asm = Assembly.GetExecutingAssembly(); using (Stream imageStream = asm.GetManifestResourceStream(resourcePath)) { using (Image theImage = Image.FromStream(imageStream)) { theImage.Save(context.Response.OutputStream, ImageFormat.Gif); } } }
Wednesday, December 14, 2011
ASP.net load an image from embedded resource
Below is a simple method that I couldn't find anywhere else online that loads a .gif image from an embedded resource and returns the image as the web page response
Labels:
Code
Deploying console apps
You can check out my blog post on deploying console apps on the Dont Panic Labs Blog
http://blog.dontpaniclabs.com/post/2011/12/14/Deploying-Console-Apps-via-MSBuild.aspx
http://blog.dontpaniclabs.com/post/2011/12/14/Deploying-Console-Apps-via-MSBuild.aspx
Subscribe to:
Posts (Atom)