Search code examples
javascriptc#asp.net-mvcaudiowav

How can add .mp3 or .wav file in asp.net mvc project?


I want to play a warning sound using javascript in the cshtml file. I want to put the audio file ( wav or mp3) under the content directory. I want to play this file in the script using the audio library. I tried to add the file with drag and drop on top of the project but it didn't. I don't want to do a database-related operation.

Solution: Following the steps, I added the audio file to the bottom of the folder I wanted. "Right click > Add> Existing item"


Solution

  • You should copy the file in a directory in the project and you should let IIS know that mp3 files are legal. For doing this you have to add MIME type in your project's web.config

    Please check this LINK for more information about how to add mp3 files mime type in web.config