Results 1 to 4 of 4

Thread: [RESOLVED] File download

  1. #1

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,857

    Resolved [RESOLVED] File download

    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

    Any help is appreciated. THX
    Last edited by dbasnett; Apr 14th, 2025 at 05:01 PM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,511

    Re: File download

    First thing I would check is the IIS logs to see what (if any) errors/error types are being logged in these cases. Is it possible that they are just 404'ing due to some sort of path change due to the server upgrade?

    What was upgraded? The OS on the same hardware? Or a full server replacement?

    It could be as simple an issue like the MIME type for .docx just needs to be added in IIS.

  3. #3

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,857

    Re: File download

    Quote Originally Posted by OptionBase1 View Post
    First thing I would check is the IIS logs to see what (if any) errors/error types are being logged in these cases. Is it possible that they are just 404'ing due to some sort of path change due to the server upgrade?

    What was upgraded? The OS on the same hardware? Or a full server replacement?

    It could be as simple an issue like the MIME type for .docx just needs to be added in IIS.
    Checked the log, no errors.

    It was a full server replacement.

    We checked the MIME type and .docx is there.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,857

    Re: File download

    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width