Hi nauna,
Please refer below code.
To display the image use WebClient class and then get the image in bytes array and use the ImageUrl using ToBase64String of Convert class.
HTML
<asp:Image ID="imgUrl" runat="server" />
Namespaces
C#
using System.IO;
using System.Net;
VB.Net
Imports System.IO
Imports System.Net
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var url = ("https://countryflagsapi.com/png/PK");
WebClient webClient = new WebClient();
byte[] imageBytes = webClient.DownloadData(url);
imgUrl.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(imageBytes);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) andles Me.Load
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
Dim url = ("https://countryflagsapi.com/png/PK")
Dim webClient As WebClient = New WebClient()
Dim imageBytes As Byte() = webClient.DownloadData(url)
imgUrl.ImageUrl = "data:image/jpeg;base64," & Convert.ToBase64String(imageBytes)
End Sub