--泛型處理常式的內容
using ThoughtWorks.QRCode.Codec;
using ThoughtWorks.QRCode.Codec.Data;
using ThoughtWorks.QRCode.Codec.Util;
using System.IO;
using System.Text;
public class GetQRCode : IHttpHandler {
public void ProcessRequest (HttpContext context) {
String data = context.Request["CodeText"];
if (!string.IsNullOrEmpty(data))
{
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
qrCodeEncoder.QRCodeScale = 4;
qrCodeEncoder.QRCodeVersion = 8;
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
System.Drawing.Bitmap image = qrCodeEncoder.Encode(data);
System.IO.MemoryStream MStream = new System.IO.MemoryStream();
image.Save(MStream, System.Drawing.Imaging.ImageFormat.Png);
context.Response.ClearContent();
context.Response.ContentType = "image/Png";
context.Response.BinaryWrite(MStream.ToArray());
}
context.Response.Flush();
context.Response.End();
}
--顯示qrcode的頁面程式
Image1.ImageUrl = "../UserControl/GetQRCode.ashx?CodeText=" + CodeText;
原先這樣可以使用,可是要搬到共用的程式裡面,泛型處理常式的程式如何改成app_code的共用程式中,因為image使用方式有限制。