<%@ WebHandler Language="C#" Class="index" %> using System; using System.Web; using ZXing; using ZXing.Common; using System.Drawing; using System.Drawing.Imaging; public class index : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; EncodingOptions eo = new EncodingOptions(); eo.Width = 400; eo.Height = 100; eo.Margin = 2; BarcodeWriter bw = new BarcodeWriter(); bw.Options = eo; bw.Format = BarcodeFormat.CODE_128; Bitmap bm = bw.Write(context.Request["barcode"] is object ? context.Request["barcode"].ToString() : "12345678901"); //bm.Save(context.Server.MapPath("barcode.jpg"), ImageFormat.Jpeg); HttpResponse Response = context.Response; Response.ClearContent(); Response.ContentType = "image/jpeg"; bm.Save(Response.OutputStream, ImageFormat.Jpeg); bm.Dispose(); } public bool IsReusable { get { return false; } } }