-
Apr 15th, 2025, 08:02 AM
#1
[RESOLVED] File Dowload from Server
I have used the following code for several years and never had an issue down loading .docx file from our web site to the user.
Code:
Dim fi As New IO.FileInfo(FileName)
'Resp is a HttpResponse from DwnLD.aspx.vb
Resp.Clear()
Resp.ClearHeaders()
Resp.ClearContent()
Resp.AppendHeader("Content-Disposition", "attachment; filename=" & IO.Path.GetFileName(FileName))
Resp.AppendHeader("Content-Length", fi.Length.ToString())
'hmmm....
' "application/octet-stream"
'for .docx files
' "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
' Resp.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessing*?ml.document"
Resp.ContentType = System.Web.MimeMapping.GetMimeMapping(FileName)
Resp.TransmitFile(FileName)
Resp.Flush()
We recently updated the server and now users can't download the files. We get a file name and network error in the download files drop down. Don't have the error when running in the development environment.
Windows server version - 24H2
IIS Version - 10.0.26100.1
Checked the IIS log, no errors.
It was a full server replacement.
We checked the MIME type and .docx is there.
Any help is appreciated. THX
-
Apr 15th, 2025, 09:34 AM
#2
Re: File Dowload from Server
This seems to have fixed the issue, the Resp.End.
Code:
Dim fi As New IO.FileInfo(FileName)
'Resp is a HttpResponse from DwnLD.aspx.vb
Resp.Clear()
Resp.ClearHeaders()
Resp.ClearContent()
Resp.AppendHeader("Content-Disposition", "attachment; filename=" & IO.Path.GetFileName(FileName))
Resp.AppendHeader("Content-Length", fi.Length.ToString())
'hmmm....
' "application/octet-stream"
'for .docx files
' "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
' Resp.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessing*?ml.document"
Resp.ContentType = System.Web.MimeMapping.GetMimeMapping(FileName)
Resp.TransmitFile(FileName)
Resp.Flush()
Resp.End() '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
Apr 15th, 2025, 12:45 PM
#3
Re: [RESOLVED] File Dowload from Server
It is interesting that that solved it, I'm curious why it would have worked in the past but not now. Maybe something changed in the new IIS that made it less "forgiving" in cases like this.
Glad you got it working. You should mark the thread in the Classic ASP forum as resolved as well since it is a duplicate of this one.
-
Re: [RESOLVED] File Dowload from Server
 Originally Posted by OptionBase1
It is interesting that that solved it, I'm curious why it would have worked in the past but not now. Maybe something changed in the new IIS that made it less "forgiving" in cases like this.
Glad you got it working. You should mark the thread in the Classic ASP forum as resolved as well since it is a duplicate of this one.
Shocked me as well. It was a why not try it, followed by a WTH!
Marked other resolved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|