1

ボタンクリックで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");
    }

ここでは、画像が完全に表示されています。ビューとは別のポップアップとして画像を表示する方法。

4

1 に答える 1

0

ポップアップのように表示する代わりに、以下のコードを使用して直接画像を取得しました。

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 に答える