469,081 Members | 1,413 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,081 developers. It's quick & easy.

Automatic download start

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?
Jun 23 '06 #1
2 2318
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" <ja**@ulvandebe.rg> wrote in message
news:n4*****************************@40tude.net...
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?

Jun 23 '06 #2
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...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" <ja**@ulvandebe.rg> wrote in message
news:n4*****************************@40tude.net...
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?

Jun 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by William Ryan | last post: by
2 posts views Thread by Trygve Lorentzen | last post: by
1 post views Thread by Iulian | last post: by
1 post views Thread by rdemyan via AccessMonster.com | last post: by
6 posts views Thread by Mike Saunders | last post: by
25 posts views Thread by sidd | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.