Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:32:14+00:00 2026-06-03T16:32:14+00:00

I am having an anchor link on the page which points to an MP3

  • 0

I am having an anchor link on the page which points to an MP3 file. I want to be able to download this file with Right-click + Save Target As.. and also by single clicking on the link.

Currently, I am facing a problem where different browsers have different behavior. IE plays the file in WMP, Firefox prompts the download box and Chrome starts playing file inline. Expected behavior on single click is that browser should either download the file or give me a download dialog.

I have tried following:

  • Creating a hidden iframe on the page and giving it is as target for my anchor link, also tried creating a form with my desired MP3 file location as its action inside this iframe and submitting the form on anchor link click event
  • Setting window.location = MP3 URL on link click
  • Tried multiple combinations of window.open

None of these has been able to help me. I just can’t get the download dialog on link-click.

The innocent anchor link looks like:

<a id="someID" href="myMP3file" target="whatever" title="Download" class="someClass">Download Me!</a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:32:16+00:00Added an answer on June 3, 2026 at 4:32 pm

    @CrabBucket – Here’s how I solved my issue!!
    Works great for me 🙂
    I was using a controller action to initiate this download from this server side (this is why I did not use a handler). Returning an http response from the controller seemed tricky initially but then I figured out a way to cheat the thing 😉
    I had to write the following code inside my controller action –

    {
        HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(FileURL);
        HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
    
        Stream myStream = myResponse.GetResponseStream();
    
        Response.ContentType = "application/octet-stream";
        Response.AddHeader("Content-Disposition", "attachment; filename=\"SaveMe.MP3\"");
    
        var readBytes = 10000000;
        var myAudResponse = new byte[readBytes];
        int fileLength;
        do {
            fileLength = myStream.Read(myAudResponse, 0, (int)readBytes);
            Response.OutputStream.Write(myAudResponse, 0, fileLength);
            Response.Flush();
        } while (fileLength > 0);
        myStream.Close();
    
        return new EmptyResult();
    }
    

    Use the basic Try-Catch, etc as per your wisdom 🙂
    A lot of thanks to various web-forums and also to CrabBucket (the SO question from where you posted the code, had an answer which was very much help!) goes without saying!


    Sorry for multiple edits! My code failed for a moment. I guess, loops are always the way to go!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an anchor link in aspx page like: <a id=Anchorclass=myAnchor href=Myproject/Mypage.aspx?myTag=asp>Go</a> I
I am calling a function test() on an anchor tag like this:- <a class=link
I am having a little trouble getting this to work. I have several anchor
I am developing a android application in which it having Userguide Page, which has
How would I access(throught JavaScript) an anchor element without it having any attributes except
Having trouble with an .htaccess file on WAMP. Works on the live server, but
Using java, I am writting a script to anchor link an html bibliography. That
What is different of having a facebook share button just by having an anchor
I'm having this weird problem with HtmlUnit in Java. I am using it to
I'm having some trouble with a Link Button generating incorrect mark up. It should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.