locked
Why this download code is not working? RRS feed

  • Question

  • User-2129876459 posted
    ----Aspx page table for href

     

    Step1:

    /***-Down() Javascript Function***/

    function down() { document.getElementById("sub_hidden").value = "SSS"; }

     

     Step2: under page_load

    if (sub_hidden.Value.Equals("SSS")) download();

    /*****Code Behind Download Logic ****

    Step3:

    protected void download()

    { //Update the Tools downloads numbers

    string Temp_file = "C:\\download\\Submission_Template.doc";

     FileStream liveStream = new FileStream(Temp_file, FileMode.Open, FileAccess.Read); byte[] buffer = new byte[(int)liveStream.Length]; liveStream.Read(buffer, 0, (int)liveStream.Length); liveStream.Close(); Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Length", buffer.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + Temp_file); Response.BinaryWrite(buffer); Response.End(); } 

     

      Any idea as why this download is not working. I clicked "Download" from the UI. But, still the download is not working. I am exhausted. Any helps please?

     

    Thanks!

    Santhosh

    Wednesday, January 16, 2008 11:48 AM

Answers

All replies

  • User-803228599 posted

    Did you hook up your down() function to the click event of your download link?

    Wednesday, January 16, 2008 12:39 PM
  • User1672132137 posted

     Check below link

    Download Files in ASP.NET

    HC 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 16, 2008 1:21 PM
  • User-2129876459 posted

    yeah i did....

     

    Thanks!

    Santhosh 

    Wednesday, January 16, 2008 1:52 PM