I have a site that allows users to upload a document such as pdf, word, excel etc.
Now in my code, when I want to show the document in a browser, I am checking for the extension and setting the ContentType appropriately.
However, this switch statement just doesn’t sound like the best solution.
Is there a way I can set the content type based on the Stream?
If you don’t want to use switch like statements, use Dictionary to add possible
MIME-entries.and set content type,
I’ve found an interesting stackoverflow thread – Using .NET, how can you find the mime type of a file based on the file signature not the extension