J
Jordan
Hi. Hoping I can get some advice...
I have an XML format Word document stored on the server. When I open it
from the server, it opens fine in Word. When I attach it to an email,
and send it to a user (using ASP.NET), it attachs good and opens in
Word.
When I attempt to allow a user to download the file off the website,
using a force download, it does NOT open in word. I looked into it
deeper and the downloaded file has a blank new line entered to the
bottom after the XML stops, causing Word to think there is an error.
Here is my code. Any reason this isn't working if it works the other
ways?
Dim path As String = Server.MapPath("report\" &
"Report.doc")
Dim file As System.IO.FileInfo = New
System.IO.FileInfo(path)
If file.Exists Then 'set appropriate headers
Response.Clear()
Response.ContentType = "Application/msword"
Response.AddHeader("Content-Disposition",
"attachment; filename=" & file.Name)
Response.AddHeader("Content-Length",
file.Length.ToString())
Response.Flush()
Response.WriteFile(file.FullName)
Else
Response.Write("This file does not exist.")
End If
I have an XML format Word document stored on the server. When I open it
from the server, it opens fine in Word. When I attach it to an email,
and send it to a user (using ASP.NET), it attachs good and opens in
Word.
When I attempt to allow a user to download the file off the website,
using a force download, it does NOT open in word. I looked into it
deeper and the downloaded file has a blank new line entered to the
bottom after the XML stops, causing Word to think there is an error.
Here is my code. Any reason this isn't working if it works the other
ways?
Dim path As String = Server.MapPath("report\" &
"Report.doc")
Dim file As System.IO.FileInfo = New
System.IO.FileInfo(path)
If file.Exists Then 'set appropriate headers
Response.Clear()
Response.ContentType = "Application/msword"
Response.AddHeader("Content-Disposition",
"attachment; filename=" & file.Name)
Response.AddHeader("Content-Length",
file.Length.ToString())
Response.Flush()
Response.WriteFile(file.FullName)
Else
Response.Write("This file does not exist.")
End If