I'm creating a csv file on the fly in my ASP.NET web app and sending it back to the user using the following code
ExportPlacementListPostModel postModel = CreatePostModelFromRequest();
MemoryStream stream = PlacementDatabaseController.ExportPlacementList(postModel);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment; filename=studentplacement.csv");
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(stream.GetBuffer());
Every time I download the file the web pages html is being appended onto the document.
Can anyone see what i am doing wrong here.
Colin G