title: Download mp3 file at browser through API .net core
body: <p>Was trying to download an mp3 file in a browser through the API that I created. But instead of receiving an mp3 file. I keep getting JSON format response. I had referred from answer in <a href="https://stackoverflow.com/questions/42460198/return-file-in-asp-net-core-web-api">return-file-in-asp-net-core-web-api</a>, but still, I can't download the mp3 file.
  Is there any mistake that I've overlooked, please kindly help?</p>
  <p>This is my downloading method from UI</p>
  <pre><code>void DownloadRecording(RecordingHistory voicehistory)
  {
        try
        {
            using (var client = new WebClient())
            {
                client.DownloadFile(&quot;https://2d489fd863a2.ngrok.io/api/download/&quot; + voicehistory.RecordingId + &quot;.mp3&quot;, voicehistory.RecordingId + &quot;.mp3&quot;);
            }
  
        }
        catch { }
  }
  </code></pre>
  <p>This is my api function for downloading mp3 from server</p>
  <pre><code> [HttpGet(&quot;download/{recordingFile}&quot;)]
   public async Task&lt;IActionResult&gt; DownloadVoiceRecording(string recordingFile)
   {
        string filePath = Directory.GetCurrentDirectory() + @&quot;\audio\Processed\&quot; + recordingFile;
        var memory = new MemoryStream();
        using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
        {
             await stream.CopyToAsync(memory);
        }
        memory.Position = 0;
        var types = GetMimeTypes();
        var ext = Path.GetExtension(filePath).ToLowerInvariant();
  
        return File(filePath, types[ext], recordingFile);
        }
  
        private Dictionary&lt;string, string&gt; GetMimeTypes()
        {
            return new Dictionary&lt;string, string&gt;
            {
                {&quot;.mp3&quot;, &quot;audio/mpeg&quot;},
                {&quot;.wav&quot;,&quot;audio/wav&quot; }
            };
        }
  </code></pre>
  <p>This is the response I get from browser and Postman</p>
  <pre><code>{
      &quot;Version&quot;: &quot;2.0.0.0&quot;,
      &quot;StatusCode&quot;: 200,
      &quot;Message&quot;: &quot;Status 200 OK&quot;,
      &quot;Result&quot;:&quot;��@� ... ... /// A lot of random symbol here
  }
  </code></pre>