开发者

How to get ContentType for file in ASP.NET MVC when using File Action Method

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,


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜