I have created a CSV file on the server and want to send it to the user using the following code:
Dim strPhysicalPath As String
strPhysicalPath = Server.MapPath( "CSV/" & PathVirtual)
Dim objFileInfo As System.IO.FileInfo = New System.IO.FileInfo(strPhysicalPath)
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "attachment; filename=" & objFileInfo.Name)
Response.AddHeader("Content-Length", objFileInfo.Length.ToString())
Response.WriteFile(strPhysicalPath)
Response.Flush()
Response.End()
This seems to work fine except when the downloaded file is viewed in Excell the html code behind the page from which it came is also appended to the file. Does anyone have any idea why it does this? Thanks.Please guide me as i am a newbie in asp.net.Thanks in advance.