如何显示像从视图弹出图像

本文关键字:视图 图像 何显示 显示 | 更新日期: 2023-09-27 18:06:18

我使用MessagingToolkit.QRCode.dll创建了一个QR码图像。我已将映像保存在磁盘中。如何显示图像单独从视图弹出??
这是我的控制器代码:

[HttpPost]
 public ActionResult GenerateQR(string Command, FormCollection collection)
    {
    // qr code logic //
       QRCodeEncoder encoder = new QRCodeEncoder();
       Bitmap img = encoder.Encode(qrcode);
       img.Save(@"D:''Capture.png", ImageFormat.Jpeg);
    // Checking the image present in the filepath and displaying the image.
       string filePath = @"D:''Capture.png";
       if (!System.IO.File.Exists(filePath))
          return Content("<script language='javascript' type='text/javascript'>alert('The Image is not available.');</script>");
       else
          return new FilePathResult(filePath, "image/png");
    }

此处图像完全显示在视图中。如何显示图像作为单独的弹出窗口从视图

如何显示像从视图弹出图像

我使用下面的代码直接获得图像,而不是弹出窗口。

QRCodeEncoder encoder = new QRCodeEncoder();
Bitmap img = encoder.Encode(qrcode);
string path = Server.MapPath(@"/Images/QRCode.jpg");        
img.Save(path, ImageFormat.Jpeg);        
return base.File(path,"image/jpeg","QRCode.jpg");