Thanks Billy for suggestions.
Hi AlexB,
Here are 3 Members of Response:
Clear Clears all content output from the buffer stream.
Flush Sends all currently buffered output to the client.
End Sends all currently buffered output to the client, stops execution of
the page, and raises the Application_EndRequest event.
So, the code should be like this:
//Response.Flush();
Response.Clear ();
Response.WriteFile(strFileToDownload);
Response.End ();
Hope this helps.
Best Regards,
Lewis
Get Secure! - <www.microsoft.com/security>
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "AlexB" <(E-Mail Removed)>
| Sender: "AlexB" <(E-Mail Removed)>
| Subject: downloading a file in ASP.NET app
| Date: Fri, 1 Aug 2003 13:45:24 -0700
| Lines: 19
| Message-ID: <03d401c3586d$d52ecec0$(E-Mail Removed)>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNYbdUuIaLhfqpbSbWrlNVaajyWHQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:103166
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| I'm trying to download a text file to an IE client using
| the following code. The problem is that the saved file
| also includes the html for the page.
|
| Any ideas anyone?
|
|
| Private Sub Button5_Click(ByVal sender As System.Object,
| ByVal e As System.EventArgs) Handles Button5.Click
|
| Dim strFileToDownload$ = "C:\test.log"
| Response.ContentType = "application/octet-stream"
| Response.AddHeader("Content-
| Disposition", "attachment; filename = " &
| System.IO.Path.GetFileName(strFileToDownload))
| Response.Flush()
| Response.WriteFile(strFileToDownload)
|
| End Sub
|
|