© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
8 replies
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);
        }
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>
<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! 🙂
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Page debugging twice in razor pages PageRouteModelConvention
C#CC# / help
4y ago
Display value of EnumMember on Razor Page View
C#CC# / help
4y ago
❔ Razor Pages Session for revalidating Page Model
C#CC# / help
3y ago
✅ Razor page not updating properly
C#CC# / help
17mo ago