I have a controller method that returns image from MongoDB, and I want to show it in my view:
<HttpPost()>
Function ShowImage(cardNumber As String) As FileContentResult
Dim Handler = New MongoDBHandler()
Dim newString = cardNumber.Replace(vbLf, "").Trim().Replace("""", String.Empty)
Dim byteArray = Handler.ReadImage(newString)
Return File(byteArray, "image/png")
End Function
I have the javascript function:
function postCardNumber(elm) {
var CardNumber = $(elm).closest("tr").find(".card-number").html();
var $img = $('<img>');
$img.attr('src', "data:image;base64," + @Html.Action("ShowImage", "CreditCard", CardNumber));
$("#myModal").append($img);
}
But there is a red underline under "CardNumber" parameter for the attr
function.
Why?