Generate a QR code,

Source: Internet
Author: User

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 ;}}}

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.