Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

Solved File download not working

Posted on 2016-08-06
Medium Priority
Last Modified: 2016-08-06

I have the following code in my site to download a zipped file that contains a .exe file.
It works fine in debug mode but nothing seems to happen at the following site address
It is the first image button with the title (1) Standalone Access solution

    Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton1.Click

        Dim filename As String = Server.MapPath("~/Download_File/")
        Dim fileInfo As New System.IO.FileInfo(filename)

        If fileInfo.Exists Then
            Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name)
            Response.AddHeader("Content-Length", fileInfo.Length.ToString())
            Response.ContentType = "application/octet-stream"
        End If
    End Sub
Question by:Murray Brown
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 10

Accepted Solution

Prakash Samariya earned 2000 total points
ID: 41745466
Wild guess, Please try something like below

Dim filename As String = Server.MapPath("~/Download_File/")
Dim fileInfo As New System.IO.FileInfo(filename)

'Set  content type for downloading file
Response.AddHeader("content-disposition", "attachment;filename="+fileInfo.Name )
Response.ContentType = "application/vnd.xls"
Response.Charset = ""

Open in new window


Author Closing Comment

by:Murray Brown
ID: 41745938

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question