public JsonResult CreateQrCode(string content) { string url = null; try { QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H); QrCode qrCode; bool ok = qrEncoder.TryEncode(content, out qrCode); if (ok) { GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Two), Brushes.Black, Brushes.White); using (MemoryStream stream = new MemoryStream()) { renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, stream); UploadResult ur = new UploadResult() { State = UploadState.Unknown, OriginFileName = string.Format("{0}.png", UpYun.StreamMd5(stream)), }; ImageOperate imgOpe = new ImageOperate(ur); imgOpe.UpLoad(ur.OriginFileName, stream); url = ur.Url; } //string md5 = UpYun. } } catch (Exception ex) { url = null; logger.Error(ex); } return(Json(new { Status = (url == null) ? "error" : "ok", Url = url, })); }