Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I am trying to provide a button for a user to click and then they download a file from my web page. The problem I am having with this code is that it sends the file to user, but at the end of the file is tacked on the html of the page itself. How can I get rid of that part at the end?

 

http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html

 

The important part of the code is as follows:

 

string filename = Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/octet-stream";

Response.AddHeader("Content-Disposition",@"attachment; filename=" + filename + "");
Response.Flush();
Response.WriteFile(filepath);

Edited by PlausiblyDamp
Wanna-Be C# Superstar

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...