.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to Download files using asp.net?

Posted By: Murali     Posted Date: December 12, 2011    Points:5   Category :ASP.Net
Hi,

I am developing a project where, the user can upload and download the files. I completed the upload option and displayed the file name which is uploaded to the server.

Now, if user need those files, then he can able to download the selected file (which is uploaded recently). I don't know how to download those files and its contents.
I need to put a download link, it is possible to download those files in asp.net?

Could anybody help me plz?

Responses
Author: Amit Mehra             
Posted Date: December 13, 2011     Points: 20   

Hi,

You can give hyperlink to hose file and browser will automatically show open or download link..Let me know if you want to force user to download only

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Murali             
Posted Date: December 13, 2011     Points: 20   

Hi,

I was inserted Download link , but i don't no how to write download code!


Author: Amit Mehra          Accepted Answer   
Posted Date: December 13, 2011     Points: 40   

Hi,

In the page load event of the download file (lets say download.aspx.cs file) write the following code

Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=yourFileName.gif");

Response.ContentType = "image/GIF";
Response.WriteFile(Server.MapPath(@"~/your file path));

Response.End();

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Murali             
Posted Date: December 14, 2011     Points: 20   

Thanks a lot! I tried u r code, it's working!!



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend