1

我在单击按钮时使用MessagingToolkit.QRCode.dll创建了一个二维码图像。我已将图像保存在磁盘中。如何将图像与视图分开显示为弹出窗口?
这是我的控制器代码:

[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");
    }

此处图像完全显示在视图中。如何将图像显示为与视图分开的弹出窗口。

4

1 回答 1

0

Instead of bringing like a popup, I got the image directly from using the below code.

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");
于 2013-04-17T10:52:08.980 回答