Excel file showing aspx page after download from web folder

HolyCow

New Member
I am using the following code to download an excel file from my asp.net/vb.net website:\[code\]Dim msFilePath As StringDim msFileName As StringmsFilePath = Server.MapPath("~/Template.xls")msFileName = msFilePathDim mAttachFileName As String = "Template.xls"Response.Clear()Response.ContentType = "application/vnd.ms-excel"Response.AddHeader("Content-Disposition", "attachment; filename=""" & mAttachFileName & """")Response.Flush()\[/code\]The excel file is a template being provided with column headings and that is all it contains. When I click on the download button in my website it prompts me to save/open the file with the correct name 'Template.xls'. Once I open it is displaying the aspx page inside the excel file instead of the data that is supposed to be in the file and giving me an error saying it is missing the css file. I have debugged through and the path is pointing to the correct location of the file so I'm not sure what is causing the problem. Any help appreciated!!
 
Back
Top