By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

Automatic download start

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.