ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Download file from URL using C# and VB.Net in ASP.Net<p>You can refer below link for your reference also you can refer below sample code for your reference.</p> <p><strong><a href="https://www.aspforums.net:443/Threads/976223/How-to-convert-any-URL-to-Image-in-ASPNet/">How to convert any URL to Image in ASP.Net</a></strong></p> <p>Refer the below sample code for your reference.</p> <p><span style="text-decoration: underline;"><strong>C#</strong></span></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { System.Net.WebClient webClient = new System.Net.WebClient(); string url = &#34;https://static.flickr.com/66/199481236_dc98b5abb3_s.jpg&#34;; byte[] bytes = webClient.DownloadData(url); string fileName = (url.Split(&#39;/&#39;)[url.Split(&#39;/&#39;).Length - 1]).Split(&#39;.&#39;)[0]; Response.ContentType = &#34;image/png&#34;; Response.AppendHeader(&#34;Content-Disposition&#34;, &#34;attachment; filename=&#34; + fileName); Response.BinaryWrite(bytes); Response.End(); }</pre> <p><span style="text-decoration: underline;"><strong>VB.Net</strong></span></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim webClient As System.Net.WebClient = New System.Net.WebClient() Dim url As String = &#34;https://static.flickr.com/66/199481236_dc98b5abb3_s.jpg&#34; Dim bytes As Byte() = webClient.DownloadData(url) Dim fileName As String = (url.Split(&#34;/&#34;c)(url.Split(&#34;/&#34;c).Length - 1)).Split(&#34;.&#34;c)(0) Response.ContentType = &#34;image/png&#34; Response.AppendHeader(&#34;Content-Disposition&#34;, &#34;attachment; filename=&#34; &amp; fileName) Response.BinaryWrite(bytes) Response.[End]() End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><span style="text-decoration: underline;"><strong><img src="https://i.imgur.com/H9ihV7M.gif" alt="" width="472" height="299" /></strong></span></p>https://www.aspforums.net:443/Threads/168603/Download-file-from-URL-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/168603/Download-file-from-URL-using-C-and-VBNet-in-ASPNet/Thu, 19 Apr 2018 00:28:55 GMT