3

I have a WEB API in dotnet that returns a File

for example

  var fileResult = File(wavAudioBytes, "audio/mpeg");

then return it

 [HttpGet]
 public IActionResult Get()
 {
    
     var fileResult = File(wavAudioBytes, "audio/mpeg");

     return fileResult;
 }

I wanted to know if File contentType if there is a list or built in class that has all the supported list of contentTypes that File supports as its just a string and i don't know which ones it dose or dose not ? Specifically for audio files.

2
  • 2
    That parameter ends up being the mime type header of the HTTP response, effectively just a string. It's use is to guide the browser on how to use the file, but nothing else. You can check the list of recognized mime types here: iana.org/assignments/media-types/media-types.xhtml Commented Feb 5 at 15:14
  • 2
    One liner: var fileResult = File(wavAudioBytes, MimeMapping.GetMimeMapping("FileName")); Commented Feb 5 at 16:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.