1.添加QRCoder包引用
2. public IActionResult MakeQrCode()
{
string url="https://www.baidu.com";
var generator = new QRCodeGenerator();
var codeData = generator.CreateQrCode(str,QRCodeGenerator.ECCLevel.M,true);
var qrcode = new QRCode(codeData);
var qrImage = qrcode.GetGraphic(100,Color.Black,Color.White,true);
var ms = new MemoryStream();
//图片格式指定为png
qrImage.Save(ms,ImageFormat.Jpeg);
byte[] bytes = ms.GetBuffer();
ms.Close();
return File(bytes, "image/Png");
}