Reputation: 2313
I want to leave as null or show as an image if that byte array image existing in DB column.
Currently I'm showing its like this
<img src="data:image;base64,@System.Convert.ToBase64String(Model.ProfilePicture)" width="80" height="80" />
but when this Model.ProfilePicture
null I'm getting error like following
Value cannot be null. Parameter name: inArray
Upvotes: 0
Views: 613
Reputation:
Wrap the <img>
tag in a if
block that check if the property has a value
@if (Model.ProfilePicture != null)
{
<img src="data:image;base64,@System.Convert.ToBase64String(Model.ProfilePicture)" width="80" height="80" />
}
Upvotes: 1