|
-
Aug 27th, 2004, 01:30 PM
#1
Thread Starter
Lively Member
download text file to client using ASP.NET
Hi All,
I am trying to download a text file around 2KB from the server onto the client using ASP.NET
The downloaded file is incomplete 500bytes only
The code is as below:
Response.ContentType = "text/plain"; // Set the file content type to text
Response.Clear();
Response.Buffer = true;
Response.Charset = ""; // Remove the charset from the Content-Type header.
this.EnableViewState = false; //Turn off the view state.
Response.AppendHeader( "Content-Disposition","attachment; filename=FileName.txt" );
Response.AppendHeader( "Content-Length", strFileName.Length.ToString() );
Response.WriteFile( "Filename.txt" ); // Write the contents of file to client
Response.Flush();
Response.End()
Can anyone tell me what is going wrong.
Any help is appreciated.
-
Aug 27th, 2004, 04:31 PM
#2
I wonder how many charact
The Content-Length you are determining by the length of 'strFileName'.
That doesn't seem correct.
VB Code:
Response.AppendHeader( "Content-Length", strFileName.Length.ToString() );
Also be aware, that the OS may appropriate 2-4kb even for a text file that only has 1 byte of data... you can duplicate and confirm this by opening NotePad, and typing 1 character, save and close. Then right-click the file, choose properties...
You will see the OS has alloted it 2 or 4kb, depending on your OS settings.
-
Aug 30th, 2004, 08:13 AM
#3
Thread Starter
Lively Member
hi nemaroller
Thanks, I was overlooking the point u mentioned.
Last edited by manju; Aug 30th, 2004 at 08:27 AM.
Thanks
Manju
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|