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:
http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html
The important part of the code is as follows:
C#:
string filename = Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",@"attachment; filename=" + filename + "");
Response.Flush();
Response.WriteFile(filepath);
Last edited by a moderator: