Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Automatic download start

Reply
Thread Tools

Automatic download start

 
 
Jan Paul van de Berg
Guest
Posts: n/a
 
      06-23-2006
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?
 
Reply With Quote
 
 
 
 
bruce barker \(sqlwork.com\)
Guest
Posts: n/a
 
      06-23-2006
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" <(E-Mail Removed)> wrote in message
news:n4negdklub2q$(E-Mail Removed)...
>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?



 
Reply With Quote
 
 
 
 
Jan Paul van de Berg
Guest
Posts: n/a
 
      06-26-2006
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" <(E-Mail Removed)> wrote in message
> news:n4negdklub2q$(E-Mail Removed)...
>>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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Download start... =?Utf-8?B?SXVsaWFu?= ASP .Net 1 08-30-2005 12:33 AM
automatic start-up programs Robyn Wagner ASP .Net 2 01-14-2005 09:54 PM
Automatic build process + automatic NuNit (2 in 1 solution) ASP .Net 1 06-29-2004 04:15 PM
Re: Automatic application start when IIS starts (not only on the first request)! Jody Fisher ASP .Net 0 07-28-2003 11:24 PM



Advertisments