Generate a QR code,
I am a newbie and keep a simple record of things. At present, it is mainly for the sake of my own future loss.
ThoughtWorks. QRCode. dll is required
Project
HtmlPage.html code
<! DOCTYPE html>
Handler. aspx code
<% @ WebHandler Language = "C #" Class = "Handler" %> using System; using System. web; using ThoughtWorks. QRCode. codec; public class Handler: IHttpHandler {public void ProcessRequest (HttpContext context) {// The text information to be generated is as follows: https://www.baidu.com/ String a = context. request. queryString ["msg"]; QRCodeEncoder qrCodeEncoder = new QRCodeEncoder (); // encoding mode qrCodeEncoder. QRCodeEncodeMode = QRCodeEncoder. ENCODE_MODE.BYTE; qrCodeEncoder. QRCodeScale = 8; // set the size of the QR code. The value ranges from 1 to 40. The larger the value, the larger the size. The larger the information that can be stored, qrCodeEncoder. QRCodeVersion = 8; // set the error rate of the QR code. Options include L (7%), M (15%), Q (25%), and H (30% ), the higher the troubleshooting rate, the less information that can be stored, but the smaller the requirement on the definition of the QR code. QRCodeErrorCorrect = QRCodeEncoder. ERROR _ CORRECTION. l; System. drawing. image image = qrCodeEncoder. encode (a); string imgpath = "/img/1.jpg"; // storage path string filepath = context. server. mapPath ("~ "+ Imgpath); System. IO. fileStream fs = new System. IO. fileStream (filepath, System. IO. fileMode. openOrCreate, System. IO. fileAccess. write); image. save (fs, System. drawing. imaging. imageFormat. jpeg); // save the file fs. close (); image. dispose (); fs. dispose (); context. response. write ("{\" status \ ": 1, \" msg \ ": \" "+ imgpath +" \ "}"); context. response. end () ;}public bool IsReusable {get {return false ;}}}