Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Link Download
Hi,
i want create a temporary download link:
This is my code:
 
private void CreateLinkDownloadFile(string strLink)
    {
        // The file path to download.
        string filepath = strLink;//@"C:\shadow_copy.rar";
        // The file name used to save the file to the client's system..
        string filename = Path.GetFileName(filepath);
        try
        {
            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.ClearContent();
            response.Clear();
            response.ContentType = "application/octet-stream";
            response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ";");
            response.TransmitFile(filepath);
            response.Flush();
            response.End();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
and this is error message of IDM:
The web site page instead of a file when IDM requested this file second time. Probably this site uses temporary links and does not allow requesting the same address twice.
Try to delete this download, then start it again from your browser and, when IDM captures it, download it without a stop/pause.
Posted 1-May-13 6:15am
Edited 1-May-13 6:18am
v2
Comments
ryanb31 at 1-May-13 11:30am
   
So, IDM is giving you an error? What if you turn that off?
NguyenVanDuc at 1-May-13 12:04pm
   
the download file will not work again.
Bernhard Hiller at 2-May-13 3:39am
   
That's exactly the purpose of a temporary download link, isn't it? And you complain that it works as it ought to do???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 1 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100