how to Convert image to base64 in asp.net

In this post ,we will know about “how to Convert image to base64 in asp.net”.

Use below code to convert image to base 64.

public string ConvertImageToBase64(string imgSrc)
{
try
{
var webClient = new WebClient();
var imageBytes = webClient.DownloadData(imgSrc);
return "data:image/png;base64," + Convert.ToBase64String(imageBytes);
}
catch
{
return string.Empty;
}
}

Visit my RPA post : Rpa online training websites

Conclusion

SHARE THIS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.