Autodownload File

Discussion in 'ASP .Net' started by Mustafa Rabie, Feb 1, 2005.

  1. Hi All,

    I want to add autodownload like all the one in Downloads.com. When u click
    download now link it redirects you to a page that the file downloads the
    application after the page is loaded.
    how can i do that?

    thanks
    mustafa
    Mustafa Rabie, Feb 1, 2005
    #1
    1. Advertising

  2. Mustafa Rabie wrote:
    > I want to add autodownload like all the one in Downloads.com. When u click
    > download now link it redirects you to a page that the file downloads the
    > application after the page is loaded.
    > how can i do that?

    You need to do this:
    1) The "download" link points to page X.
    2) Page X redirects to the zip, exe or other file the user should download.

    You can pass the name of the file to download as a query string
    parameter to create a dynamic "page X".

    Anders Norås
    http://dotnetjunkies.com/weblog/anoras/
    =?ISO-8859-1?Q?Anders_Nor=E5s?=, Feb 1, 2005
    #2
    1. Advertising

  3. If you view source on their page you will see how they accomplish this.
    They are writing an iframe into the document with a src of the file to
    download.

    This code needs to be somewhere on your page.

    for the window.onLoad event the beginDownload method will be called. It
    writes out an iframe with the src attribute to download.

    The <noscript> tag is processed on browsers that do not support scripts.

    hth,

    bill

    <script language="JavaScript" type="text/javascript">
    <!--
    function beginDownload() {
    idl = -1;
    idl = location.search.indexOf("idl=n");
    if (idl < 0) document.write('<iframe height="0" width="0"
    src="http://myserver.com/downloads/file.exe"></iframe>');
    }
    window.onLoad=beginDownload();
    //-->
    </script>
    <noscript>
    <iframe height="0" width="0"
    src="http://myserver.com/downloads/file.exe"> </iframe>
    </noscript>


    "Mustafa Rabie" <> wrote in message
    news:%23aTlQ%...
    > Hi All,
    >
    > I want to add autodownload like all the one in Downloads.com. When u

    click
    > download now link it redirects you to a page that the file downloads the
    > application after the page is loaded.
    > how can i do that?
    >
    > thanks
    > mustafa
    >
    >
    William F. Robertson, Jr., Feb 1, 2005
    #3
  4. You can do like this in dotnet.

    Response.ContentType = ContentType;
    Response.AddHeader("Content-Disposition",
    "attachment;filename="+Path.GetFileName(Filename));
    Response.WriteFile(Filename);
    Response.End();


    "Mustafa Rabie" wrote:

    > Hi All,
    >
    > I want to add autodownload like all the one in Downloads.com. When u click
    > download now link it redirects you to a page that the file downloads the
    > application after the page is loaded.
    > how can i do that?
    >
    > thanks
    > mustafa
    >
    >
    >
    =?Utf-8?B?UGVuZyBKaWU=?=, Feb 1, 2005
    #4
  5. All I think you need is a META REFRESH in the download page. If the target
    page is a ZIP etc (can't be displayed visually in the browser) the browser
    will open a download dialog instead of navigating.

    I do this on my own site in ASP -
    http://www.droopyeyes.com/downloads/ecomodeler.asp



    --
    Pete
    ====
    ECO Modeler, Audio compression components, DIB graphics controls,
    FastStrings
    http://www.droopyeyes.com

    Read or write articles on just about anything
    http://www.HowToDoThings.com

    My blog
    http://blogs.slcdug.org/petermorris/
    Peter Morris [Droopy eyes software], Feb 1, 2005
    #5
  6. thank you for your replies they are very helpful, but the redirect to page x
    with the link wont work since it wont display the page.
    I want it to be when after the page is loaded and displayed it starts
    downloading.

    I think the iFrame idea is good, i can hide the iframe and redirect to the
    file from inside it.

    any feedback and comments is more than welcome of course! ;)

    thanks for your help really appreciated
    mustafa
    "Mustafa Rabie" <> wrote in message
    news:%23aTlQ%...
    > Hi All,
    >
    > I want to add autodownload like all the one in Downloads.com. When u
    > click download now link it redirects you to a page that the file downloads
    > the application after the page is loaded.
    > how can i do that?
    >
    > thanks
    > mustafa
    >
    Mustafa Rabie, Feb 1, 2005
    #6
  7. i tried that but there's no after page load function in aspx, so i can fire
    that code after the page is loaded.

    "Peng Jie" <> wrote in message
    news:...
    > You can do like this in dotnet.
    >
    > Response.ContentType = ContentType;
    > Response.AddHeader("Content-Disposition",
    > "attachment;filename="+Path.GetFileName(Filename));
    > Response.WriteFile(Filename);
    > Response.End();
    >
    >
    > "Mustafa Rabie" wrote:
    >
    >> Hi All,
    >>
    >> I want to add autodownload like all the one in Downloads.com. When u
    >> click
    >> download now link it redirects you to a page that the file downloads the
    >> application after the page is loaded.
    >> how can i do that?
    >>
    >> thanks
    >> mustafa
    >>
    >>
    >>
    Mustafa Rabie, Feb 1, 2005
    #7
  8. actually this is much easier... thanks peter i think i'll use the meta
    refresh :)
    "Peter Morris [Droopy eyes software]" <>
    wrote in message news:...
    > All I think you need is a META REFRESH in the download page. If the
    > target page is a ZIP etc (can't be displayed visually in the browser) the
    > browser will open a download dialog instead of navigating.
    >
    > I do this on my own site in ASP -
    > http://www.droopyeyes.com/downloads/ecomodeler.asp
    >
    >
    >
    > --
    > Pete
    > ====
    > ECO Modeler, Audio compression components, DIB graphics controls,
    > FastStrings
    > http://www.droopyeyes.com
    >
    > Read or write articles on just about anything
    > http://www.HowToDoThings.com
    >
    > My blog
    > http://blogs.slcdug.org/petermorris/
    >
    Mustafa Rabie, Feb 1, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Esteban Valencia Muñoz
    Replies:
    3
    Views:
    1,392
    Scott Allen
    Jun 4, 2005
  2. Prakash

    Autodownload

    Prakash, Apr 17, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    401
    Prakash
    Apr 17, 2006
  3. Dave
    Replies:
    1
    Views:
    978
    Juan T. Llibre
    Jun 8, 2007
  4. =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki

    Reading of file by next of map file and by next of file descriptor.

    =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki, Jul 10, 2007, in forum: C++
    Replies:
    1
    Views:
    779
    Alf P. Steinbach
    Jul 10, 2007
  5. Prakash

    autodownload

    Prakash, Apr 17, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    95
    Prakash
    Apr 17, 2006
Loading...

Share This Page