We have ASP.NET code that downloads files of different types to the client. On several of our servers, the file properly downloads with the correct name and extension (e.g. "helloworld.doc"). However, on another server the file is always renamed to the ASPX filename with .html extension. Thus, when the user clicks download on the web browser they see the File Download dialog with name as "aspfilename.html" and type as "HTML document" instead of "helloworld.doc" and "MS Word" respectively.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim att As New Attachment
Dim physicalPath As String
Dim fileName As String
If Me.AttachmentId > 0 Then
' If an attachment id is provided then use it to look up the file information.
att = Attachment.GetAttachmentById(Me.AttachmentId)
physicalPath = att.PhysicalPath
fileName = att.FileName
' No attachment id provided so use the file information from the parameters.
physicalPath = Me.PhysicalPath
fileName = Me.FileName
Response.AddHeader("Content-Disposition", "attachment;filename=""" + fileName + """")