Top Ad unit 728 × 90

random

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;
            }
        }



how to Convert image to base64 in asp.net Reviewed by Vikas Kumar Singh on December 03, 2017 Rating: 5

No comments:

All Rights Reserved by DotNetBasic.com © 2019

Contact Form

Name

Email *

Message *

© 2018 All rights reserved by DotNetBasic. Powered by Blogger.