/// <summary> /// 生成二维码 /// </summary> /// <returns></returns> public ActionResult QrCode(string con, string i, string bar, string hue) { return(RunAction(() => { if (!ValidateHelper.IsLenInRange(con, 1, 500)) { return Content("长度超出范围"); } var qr = new QrCode(); string img = null; if (i?.Length > 0) { img = Server.MapPath("~/Static/image/no_data.png"); } var b = ValidateHelper.IsPlumpString(bar) ? qr.GetBarCodeBytes(con) : qr.GetQrCodeWithIconBytes(con, icon_path: img); if (ValidateHelper.IsPlumpString(hue)) { b = qr.AddRandomHue(b); } if (!ValidateHelper.IsPlumpList(b)) { return Content("bytes is empty"); } this.X.context.Response.SetResponseNoCache(); return File(b, "image/Png"); })); }