Automatic download start

Discussion in 'ASP .Net' started by Jan Paul van de Berg, Jun 23, 2006.

  1. I have a piece of software that people can download and a third party
    promoting that software. In order for them to be able to count the number
    of downloads, I have to put a tracking code on my site. The tracking code
    must be sent to the client when the user clicks the download button. At the
    same time, the download must start. The download button links to this page:

    - Possibility 1, server side redirect to executable
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <html>
    <body>
    <some iframe tracking code>
    </body>
    </html>
    <%Response.Redirect("http://mysite.bla/myproggie.exe");%>

    When I do this, the tracking code is not displayed because the redirect
    happens earlier. The download does start though.

    - Possibility 2: client side redirect to executable
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <script language="javascript">
    function startDownload() {
    location.href = "http://mysite.bla/myproggie.exe";
    }
    </script>
    <html>
    <body>
    <some iframe tracking code>
    <script language="javascript"> startDownload() </script>
    </body>
    </html>

    When I do this, Windows XP SP2 users see a yellow message in the top of
    their browser that the site is trying to execute a program. I don't want
    that because it scares users away.

    - Possibility 3: client side redirect to asp page that performs a server
    side redirect
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <script language="javascript">
    function startDownload() {
    location.href = "http://mysite.bla/startdownload.asp";
    }
    </script>
    <body>
    <some iframe tracking code>
    <script language="javascript"> startDownload() </script>
    </body>
    </html>

    [startdownload.asp]
    <%Response.Redirect("http://mysite.bla/myproggie.exe");%>

    This also gives the warning in XP SP2. The strange thing is when I link the
    download button directly to startdownload.asp, there's no warning.

    How can I get this to work?
     
    Jan Paul van de Berg, Jun 23, 2006
    #1
    1. Advertising

  2. you should move the tracking code logic to the server. have an aspx page do
    the download:

    mydownloadpage.aspx?id=<download file id>&src=<third party site id>

    use Response.WriteFile and response headers to do the download. google for
    more info.

    -- bruce (sqlwork.com)

    "Jan Paul van de Berg" <> wrote in message
    news:n4negdklub2q$...
    >I have a piece of software that people can download and a third party
    > promoting that software. In order for them to be able to count the number
    > of downloads, I have to put a tracking code on my site. The tracking code
    > must be sent to the client when the user clicks the download button. At
    > the
    > same time, the download must start. The download button links to this
    > page:
    >
    > - Possibility 1, server side redirect to executable
    > <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    > <html>
    > <body>
    > <some iframe tracking code>
    > </body>
    > </html>
    > <%Response.Redirect("http://mysite.bla/myproggie.exe");%>
    >
    > When I do this, the tracking code is not displayed because the redirect
    > happens earlier. The download does start though.
    >
    > - Possibility 2: client side redirect to executable
    > <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    > <script language="javascript">
    > function startDownload() {
    > location.href = "http://mysite.bla/myproggie.exe";
    > }
    > </script>
    > <html>
    > <body>
    > <some iframe tracking code>
    > <script language="javascript"> startDownload() </script>
    > </body>
    > </html>
    >
    > When I do this, Windows XP SP2 users see a yellow message in the top of
    > their browser that the site is trying to execute a program. I don't want
    > that because it scares users away.
    >
    > - Possibility 3: client side redirect to asp page that performs a server
    > side redirect
    > <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    > <script language="javascript">
    > function startDownload() {
    > location.href = "http://mysite.bla/startdownload.asp";
    > }
    > </script>
    > <body>
    > <some iframe tracking code>
    > <script language="javascript"> startDownload() </script>
    > </body>
    > </html>
    >
    > [startdownload.asp]
    > <%Response.Redirect("http://mysite.bla/myproggie.exe");%>
    >
    > This also gives the warning in XP SP2. The strange thing is when I link
    > the
    > download button directly to startdownload.asp, there's no warning.
    >
    > How can I get this to work?
     
    bruce barker \(sqlwork.com\), Jun 23, 2006
    #2
    1. Advertising

  3. Thanks for the info. Unfortunately all examples I find assume you don't
    have a 3rd party script but just want to force the download start. I've
    tried this [1]:

    <%@ Import Namespace="System.IO"%>
    <script language="VB" runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)

    Dim filepath As String = Server.MapPath("myproggie.exe")
    If File.Exists(filepath) Then
    Dim filename As String = Path.GetFileName(filepath)
    Response.Clear()
    Response.ContentType = "application/octet-stream"
    Response.AddHeader("Content-Disposition", _
    "attachment; filename=""" & filename & """")
    Response.Flush()
    Response.WriteFile(filepath)
    End If

    End Sub
    </script>

    No matter what I try, I can't get mydownloadpage.aspx to send html to the
    browser. Not by adding Response.Write(<3rd party script>) anywhere, not by
    adding HTML. It behaves like Possibility 1 I described.

    [1] a modified version of
    http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html, all other
    references to this method I can find work the same

    Op Fri, 23 Jun 2006 08:56:09 -0700 schreef bruce barker (sqlwork.com):

    > you should move the tracking code logic to the server. have an aspx page do
    > the download:
    >
    > mydownloadpage.aspx?id=<download file id>&src=<third party site id>
    >
    > use Response.WriteFile and response headers to do the download. google for
    > more info.
    >
    > -- bruce (sqlwork.com)
    >
    > "Jan Paul van de Berg" <> wrote in message
    > news:n4negdklub2q$...
    >>I have a piece of software that people can download and a third party
    >> promoting that software. In order for them to be able to count the number
    >> of downloads, I have to put a tracking code on my site. The tracking code
    >> must be sent to the client when the user clicks the download button. At
    >> the
    >> same time, the download must start. The download button links to this
    >> page:
    >>
    >> - Possibility 1, server side redirect to executable
    >> <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    >> <html>
    >> <body>
    >> <some iframe tracking code>
    >> </body>
    >> </html>
    >> <%Response.Redirect("http://mysite.bla/myproggie.exe");%>
    >>
    >> When I do this, the tracking code is not displayed because the redirect
    >> happens earlier. The download does start though.
    >>
    >> - Possibility 2: client side redirect to executable
    >> <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    >> <script language="javascript">
    >> function startDownload() {
    >> location.href = "http://mysite.bla/myproggie.exe";
    >> }
    >> </script>
    >> <html>
    >> <body>
    >> <some iframe tracking code>
    >> <script language="javascript"> startDownload() </script>
    >> </body>
    >> </html>
    >>
    >> When I do this, Windows XP SP2 users see a yellow message in the top of
    >> their browser that the site is trying to execute a program. I don't want
    >> that because it scares users away.
    >>
    >> - Possibility 3: client side redirect to asp page that performs a server
    >> side redirect
    >> <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    >> <script language="javascript">
    >> function startDownload() {
    >> location.href = "http://mysite.bla/startdownload.asp";
    >> }
    >> </script>
    >> <body>
    >> <some iframe tracking code>
    >> <script language="javascript"> startDownload() </script>
    >> </body>
    >> </html>
    >>
    >> [startdownload.asp]
    >> <%Response.Redirect("http://mysite.bla/myproggie.exe");%>
    >>
    >> This also gives the warning in XP SP2. The strange thing is when I link
    >> the
    >> download button directly to startdownload.asp, there's no warning.
    >>
    >> How can I get this to work?
     
    Jan Paul van de Berg, Jun 26, 2006
    #3
    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. Robyn Wagner

    automatic start-up programs

    Robyn Wagner, Jan 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    447
    Cindy Winegarden
    Jan 14, 2005
  2. Jody Fisher
    Replies:
    0
    Views:
    497
    Jody Fisher
    Jul 29, 2003
  3. Guest
    Replies:
    1
    Views:
    797
    Guest
    Jun 29, 2004
  4. Lucas Tam
    Replies:
    0
    Views:
    539
    Lucas Tam
    Jun 17, 2005
  5. =?Utf-8?B?SXVsaWFu?=

    Automatic Download start...

    =?Utf-8?B?SXVsaWFu?=, Aug 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    552
    =?Utf-8?B?SXVsaWFu?=
    Aug 30, 2005
Loading...

Share This Page