[英]getting the mime of text files
I am using a piece of code someone pasted for C# which uses urlmon.dll. 我正在使用有人粘贴到使用urlmon.dll的C#的一段代码。 It reads in <= 256bytes and returns the mime based on the data.
它读取<= 256bytes,并根据数据返回哑剧。
Problem is it cant distinguishes a css file from a text/plain. 问题是它无法将CSS文件与文本/纯文本区分开。 I can goto /style.css but when including it in my html the CSS does not show up.
我可以转到/style.css,但是将其包含在html中时,CSS不会显示。 I am using urlmon + context.Response.TransmitFile to send it.
我正在使用urlmon + context.Response.TransmitFile发送它。
Hmm, I am not sure I completely understand your question, but if you want to do some sort of look up against a master list you can look at the IIS Metabase 嗯,我不确定我是否完全理解您的问题,但是如果您想根据主列表进行某种查找,则可以查看IIS元数据库
using (DirectoryEntry directory = new DirectoryEntry("IIS://Localhost/MimeMap")) {
PropertyValueCollection mimeMap = directory.Properties["MimeMap"];
foreach (object Value in mimeMap) {
IISOle.MimeMap mimetype = (IISOle.MimeMap)Value;
//use mimetype.Extension and mimetype.MimeType to determine
//if it matches the type you are looking for
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.