Asp.net Mvc Not Serving Mp3 Files
Solution 1:
I finally figured out the problem. I realized that although there was a static file mapping for the MVC Handler, that any requests would still go through the ASP.NET MVC router.
Turns out I had a custom route defined that for security reasons locked down the file types it would serve and mp3 wasn't one of them.
Solution 2:
First, you should check the path with browser's developer tools (view source) to make sure that the file path is rendered properly. Your problem seem occurred because of wrong file path.
Second, instead of creating src
path manually, use @Url.Content()
helper with relative virtual path to MP3 file like example below, make sure the correct path is used:
<audio loop="loop" autoplay="autoplay">
<source src="@Url.Content("~/mp3/myfile.mp3")"type="audio/mp3" />
</audio>
If the page is deployed in production server, make sure that MIME type audio/mp3
is enabled in IIS settings and you have read/write permission for /mp3
folder. You may check (and add) this setting inside <system.webServer>
section in either applicationHost.config
, machine.config
or web.config
file:
<staticContent><mimeMapfileExtension=".mp3"mimeType="audio/mp3" /></staticContent>
Post a Comment for "Asp.net Mvc Not Serving Mp3 Files"