C#C
C#4y ago
big OOF

Display base64 img on Razor page

Hello,

Im trying to display a base 64 image on a razor page.

Pagemodel:
public string imagedata { get; set; } = "";
        public void OnPostGetSelectedImage()
        {
            string myBase64 = "examplebase64";

            imagedata = string.Format($"data:image/png;base64", myBase64);
        }

Page:
<div class="container">
    <div class="form-group">
    <img id="UserImage" src="@Model.imagedata" alt="your image" />
</div>

The image is not showing and im woundering if this is the correct way of thinking or should i change it from void to something that reloads the page?

Thanks in advance! 🙂
Was this page helpful?