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

x
?
Solved

ASP.net File download not working

Posted on 2016-08-06
2
Medium Priority
?
76 Views
Last Modified: 2016-08-06
Hi

I have the following code in my ASP.net 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
http://automaticoffice.azurewebsites.net/Downloads
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/Automator_Installs.zip")
        Dim fileInfo As New System.IO.FileInfo(filename)

        If fileInfo.Exists Then
            Response.Clear()
            Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name)
            Response.AddHeader("Content-Length", fileInfo.Length.ToString())
            Response.ContentType = "application/octet-stream"
            Response.Flush()
            Response.TransmitFile(fileInfo.FullName)
            Response.[End]()
        End If
    End Sub
0
Comment
Question by:Murray Brown
[X]
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
2 Comments
 
LVL 10

Accepted Solution

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

Dim filename As String = Server.MapPath("~/Download_File/Automator_Installs.zip")
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 = ""
Response.TransmitFile(fileInfo.Name)
Response.Flush()
Response.Close()
Response.End()

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 41745938
Thanks
0

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