Solved

ASP.net File download not working

Posted on 2016-08-06
2
40 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:murbro
2 Comments
 
LVL 8

Accepted Solution

by:
Prakash Samariya earned 500 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:murbro
ID: 41745938
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now