Question

I created an QR code image using MessagingToolkit.QRCode.dll in a button click. I have saved the image in the disk. How to display the image separately from view as pop up ??
Here is my controller code :

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

Here the image is displayed in view completely. How to display the image as separate popup from the view.

Was it helpful?

Solution

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");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top