1

Attempting to use asp.net mvc's Action Result of File.

So it would seem that I have to specify a ContentType for the file to be sent to the browser. Currently there is no real limit to what types of files may be sent to the browser in my application, so I can't always assume it will be a "text/pdf", for example.

What's the best way of working out the ContentType of a file, or is there a way where this can be set to something 'generic'?

The simpler the better!

Thanks,

1 Answer 1

2

You either user the local machine's database of MIME types (from the registery):

http://www.codeproject.com/KB/dotnet/ContentType.aspx

or find an alternate dictionary. Like this duplicate SO question.

Sign up to request clarification or add additional context in comments.

1 Comment

If you're on .NET 4.5+, check out this answer

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.