I display a table with data on the page and then when user clicks Export I put the data in the excel file. Now I want to open this file so that user can save it or just view it. This is the code I have. It prompts the user to save a file but that file is the whole page!! WHat is wrong here?
string filename = filePath.Substring(12);
System.IO.File.Copy(filePath, "C:/Work/MCTestSuiteCertificate/TS.ToDoViewer/Content/" + filename, true);
Response.Clear();
Response.ContentType = @"application\xls";
// FileInfo file = new FileInfo(Server.MapPath("~/Content/" + filename));
Response.AddHeader("Filename", filename);
Response.ContentType = "application/xls";
Response.TransmitFile("C:/Work/MCTestSuiteCertificate/TS.ToDoViewer/Content/" + filename);
//Response.WriteFile(file.FullName);
Response.Flush();