.net core .net 6 使用二维码
作者:互联网
控制器
using Microsoft.AspNetCore.Mvc; using QRCoder; using System.Drawing; using System.IO; namespace v6bbs_core.web.Controllers { public class qrcodeController : Controller { public IActionResult index(string url) { QRCodeGenerator qrGenerator = new QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(url, QRCodeGenerator.ECCLevel.Q); QRCode qrCode = new QRCode(qrCodeData); Bitmap qrCodeImage = qrCode.GetGraphic(20); MemoryStream ms = new MemoryStream(); qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); qrCodeImage.Dispose(); return File(ms.ToArray(), "images/jpeg"); } } }
无须写Startup注入和接口。
标签:core,System,new,QRCodeGenerator,ms,using,二维码,net,qrCodeImage 来源: https://www.cnblogs.com/valu/p/16487982.html