Solved

ASP.net File download not working

Posted on 2016-08-06
2
58 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
[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 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to repeat the data 4 44
How to fix 'event logs could not be searched' error asp.net? 3 26
Data Analysis 7 59
same domain, but different cookies. why? 6 7
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

710 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