Is there a way I can automatically generate Content-Type
headers in .NET?
I'm working on a system where users upload files in many formats and the only meta-data available to me is the file extension.
One of my forms has a link to an ashx
resource that writes files to the response. I would prefer to set the appropriate content type header so the browser knows how to deal with the file if the user wants to open it directly instead of saving it.
If there isn't anything prefab available I'll have to start making my own compilation of extension to content type header mappings, but I'd prefer not having to do unnecessary work.
This answer has something similar for Java, but I couldn't find anything for .NET