Introduction
This code is provide a download functionality in Asp.Net with c#..
So to download any file in ASP.Net using C# import this namespace
Namespace
This code is provide a download functionality in Asp.Net with c#..
So to download any file in ASP.Net using C# import this namespace
Namespace
using System.Net;
Use the code
First we create source file using Button, TextBox and Label Control..
First we create source file using Button, TextBox and Label Control..
Enter path in Textbox
Example:-E-Book/HiFriends.doc
and download your file in your pc.
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td style="text-align: right">Select Path :- </td>
<td><asp:TextBox ID="txtFileName" runat="server" Width="201px"></asp:TextBox></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Download" /></td>
</tr>
</table>
</div>
</form>
</body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td style="text-align: right">Select Path :- </td>
<td><asp:TextBox ID="txtFileName" runat="server" Width="201px"></asp:TextBox></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Download" /></td>
</tr>
</table>
</div>
</form>
</body>
This Code Write in your cs file
protected void Download_Click(object sender, EventArgs e)
{
try
{
string strURL = txtFileName.Text;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(strURL) + "\"");
byte[] data = req.DownloadData(Server.MapPath(strURL));
response.BinaryWrite(data);
response.End();
}
catch (Exception ex)
{
}
}
{
try
{
string strURL = txtFileName.Text;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(strURL) + "\"");
byte[] data = req.DownloadData(Server.MapPath(strURL));
response.BinaryWrite(data);
response.End();
}
catch (Exception ex)
{
}
}
ReplyDeleteThis is the information that I was looking for.. Thanks for the efforts you put to gather such a nice content and posted here.
http://www.iqonlinetraining.com/asp-dotnet-online-training/
Excellent information with unique content and it is very useful to know about the information based on blogs.
ReplyDeleteDot Net Online Training Hyderabad
thank you for giving information Dotnet Online Training
ReplyDeleteI am glad to read this. Thank you for this beautiful content, Keep it up. Techavera is the best DTP training course in Noida. Visit us For Quality Learning.Thank you
ReplyDeletenice information,usufull to students and developers..Dot net Training In Hyderabad!
ReplyDeleteDot net Training In Ameerpet!
Dot net Certification In Hyderabad!
Nice and good article. It will helpful for dotnet students and developers.Thanks for sharing this useful information. If you want to learn dotnet course in online, please visit below site.
ReplyDeletedotnet Online Training, dotnet course, dotnet online training in kurnool, dotnet online training in hyderabad, dotnet online training in bangalore, online courses, online learning, online education, trending courses, best career courses
thank you for giving information
ReplyDeleteDot net training in Hyderabad!
ReplyDeleteNice blog..! I really loved reading through this article. Thanks for sharing such
a amazing post with us and keep blogging...
asp dotnet training in hyderabad
ReplyDeletehi your blog Article is very nice & thanks for sharing the information.
dotnet online coaching in hyderabad
salesforce online training
ReplyDeleteNice blog..! I really loved reading through this article. Thanks for sharing such
ReplyDeletea amazing post with us and keep blogging...
tableau online training hyderabad!
tableau developer course!
Nice Post. Keep sharing more and more Tableau Online Training
ReplyDeleteAWS Online training
Dot Net OnlineTraining
DevOps Online Training
Selenium Online Training
Nice post..
ReplyDeleteSSIS training
SSRS training
tableau training
Teradata training
Windows admin training
Wordpress training
Qliksense training
dot net online training dot net course
ReplyDeleteazure training
ReplyDeletejava training
salesforce training
hadoop training
mulesoft training
linux training
mulesoft training
If more people that write articles involved themselves with writing great content like you, more readers would be interested in their writings. I have learned too many things from your article.
ReplyDeletetrending courses
Excellent information with unique content and it is very useful to know about the information based on blogs.
ReplyDeleteDot Net Online Training
Visit us: Dot Net Online Training
Thank you for sharing valuable information.
ReplyDeleteVisit us: Java Online Course
Visit us: Learn Java Online
Nice informative content. Thanks for sharing the valuable information.
ReplyDelete.Net Coaching Centre in Chennai
Dot Net Online Course
DOT NET Training Institutes in Bangalore
Hi, I read your whole blog. This is very nice. Good to know about the .net and is very demanding in future. We are also providing various Microsoft .Net Training & Certification Courses, anyone interested can .net certification for making their career in this field.
ReplyDeleteThanks for sharing nice post..
ReplyDeletedot net online training
dot net online course
Jó honlap : Zonahobisaya
ReplyDeleteJó honlap : Biografi
Jó honlap : Tersempit
Jó honlap : Zonahobisaya
Jó honlap : Sinopsis Film Terbaru
Jó honlap : Zonahobisaya
Jó honlap : Zonahobisaya
Jó honlap : Zonahobisaya
Thank you for sharing such detailed Blog. I am learning a lot from you. Visit my website to get best Information About Best IAS Coaching in Navi Mumbai
ReplyDeleteBest IAS Coaching in Navi Mumbai
Top UPSC Coaching in Navi Mumbai
This blog is so cool. I am <a href="https://www.janbasktraining.com/dotnet-training>learning dot net</a> course online. This blogs helps me find out better understanding about salesforce training. Thank you for this blog!
ReplyDeleteThis is very nice. Good to know about the .net and is very demanding in future. Looking for a .Net Training Services Company in Balsua? Look no further than Satyam Technology!
ReplyDelete