Hi Nauna,
Please refer below Sample.
You can download PDF, PNG, JPEG etc.
HTML
<asp:Button Text="Download" OnClick="DownLoad" runat="server" />
Code
C#
protected void DownLoad(object sender, EventArgs e)
{
System.Net.WebClient webClient = new System.Net.WebClient();
string url = "http://www.africau.edu/images/default/sample.pdf";
byte[] bytes = webClient.DownloadData(url);
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(url));
Response.BinaryWrite(bytes);
Response.End();
}
VB.Net
Protected Sub DownLoad(ByVal sender As Object, ByVal e As EventArgs)
Dim webClient As System.Net.WebClient = New System.Net.WebClient()
Dim url As String = "http://www.africau.edu/images/default/sample.pdf"
Dim bytes As Byte() = webClient.DownloadData(url)
Response.ContentType = ContentType
Response.AppendHeader("Content-Disposition", "attachment; filename=" & System.IO.Path.GetFileName(url))
Response.BinaryWrite(bytes)
Response.End()
End Sub
Screenshot