Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Force download popup for audio file

Force download popup for audio file

Scheduled Pinned Locked Moved ASP.NET
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MayyMagdy
    wrote on last edited by
    #1

    Hi all, I'm working on a website that allows users to download audio files, the problem is that when i use a regular link with href=fileURL, this usually plays the audio file using the installed audio player. I want a method to force download dialog box to open. (Also i don't want to put the audio in .zip file and so on...) Thanks.

    T 1 Reply Last reply
    0
    • M MayyMagdy

      Hi all, I'm working on a website that allows users to download audio files, the problem is that when i use a regular link with href=fileURL, this usually plays the audio file using the installed audio player. I want a method to force download dialog box to open. (Also i don't want to put the audio in .zip file and so on...) Thanks.

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      # string strRequest = Request.QueryString("file"); # //-- if something was passed to the file querystring # if (strRequest != "") { # //get absolute path of the file # string path = Server.MapPath(strRequest); # //get file object as FileInfo # System.IO.FileInfo file = new System.IO.FileInfo(path); # //-- if the file exists on the server # if (file.Exists) { # //set appropriate headers # Response.Clear(); # Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); # Response.AddHeader("Content-Length", file.Length.ToString()); # Response.ContentType = "application/octet-stream"; # Response.WriteFile(file.FullName); # Response.End(); # //if file does not exist # } # else { # Response.Write("This file does not exist."); # }

      I didn't get any requirements for the signature

      M 1 Reply Last reply
      0
      • T ToddHileHoffer

        # string strRequest = Request.QueryString("file"); # //-- if something was passed to the file querystring # if (strRequest != "") { # //get absolute path of the file # string path = Server.MapPath(strRequest); # //get file object as FileInfo # System.IO.FileInfo file = new System.IO.FileInfo(path); # //-- if the file exists on the server # if (file.Exists) { # //set appropriate headers # Response.Clear(); # Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); # Response.AddHeader("Content-Length", file.Length.ToString()); # Response.ContentType = "application/octet-stream"; # Response.WriteFile(file.FullName); # Response.End(); # //if file does not exist # } # else { # Response.Write("This file does not exist."); # }

        I didn't get any requirements for the signature

        M Offline
        M Offline
        MayyMagdy
        wrote on last edited by
        #3

        thanks very much. It works fine. But for regular download only, i.e if i have Download Accelerator installed it always download the ".aspx" page not the audio files. any ideas?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups