Markup:
<img src="GenericHandler.ashx?f=Thumbnail" alt="Thumbnail" />Generic Handler:
public class GenericHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { string f = context.Request.QueryString.Get("f"); /// /// Option 1: from server location. /// f = @"\\servername\images\" + f + ".jpg"; /// /// Option 2: from disk location /// f = @"c:\data\images\" + f + ".jpg"; System.Drawing.Image image = System.Drawing.Image.FromFile(f); context.Response.Clear(); context.Response.ClearHeaders(); image.Save(context.Response.OutputStream, ImageFormat.Jpeg); context.Response.ContentType = "image/jpeg"; HttpContext.Current.ApplicationInstance.CompleteRequest(); } public bool IsReusable { get { return false; } } }
No comments:
Post a Comment