有没有办法让所有的M​​IME类型,而不是wrinting一个巨大的case语句? [英] Is there a way to get ALL the MIME types instead of wrinting a huge case statement?

查看:102
本文介绍了有没有办法让所有的M​​IME类型,而不是wrinting一个巨大的case语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要填充

Response.ContentType = "text/plain";

从某处的服务器/网络/字典所有可能MIME根据文件扩展类型:

From somewhere in the server/web/dictionary ALL possible MIME types according to file extension:

public string GetMimeType(string extension)
{
    //This is what I am looking for.    
}

另外,我要重命名文件(至少如果要下载,所以我必须要事先知道,如果它要被打开或没有。

Also, I have to rename the file (at least if going to be downloaded, so I have to know in advance if it's going to be opened or not.

推荐答案

您可以存储MIME类型当文件被上传(文件上传。的 PostedFile.ContentType )和发送时请求的文件。

You can store the mimetype when the file is uploaded ( FileUpload.PostedFile.ContentType ) and send that when the file is requested.

这篇关于有没有办法让所有的M​​IME类型,而不是wrinting一个巨大的case语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆