简体   繁体   English

得到文本文件的哑剧

[英]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.

相关问题 使用 MIME 下载文件时,在.Net 中未下载带有非英文字符的文件名 - While downloading files using MIME the file Name with non-english characters are not getting downloaded in .Net 在C#中使用mime类型保存文件 - Save files with mime type in c# 从原始 email 文本构建 MIME 消息 - Build MIME message from raw email text 获取要在asp.net Web应用程序中读取的文本文件的完整路径 - getting fullpath of text files to be read in asp.net web application 从Web服务响应标头获取MIME类型 - Getting MIME type from Web Service Response header Xamarin Android,使用 CrossDownloadManager 下载文件时指定 MIME 类型 - Xamarin Android, specify MIME type when downloading files using CrossDownloadManager 如何使用C#获取在线文件的MIME类型 - How to get mime type of online files using c# Mailkit-在没有完整的mime消息的情况下获取HTML和Text部分 - Mailkit - Get HTML and Text parts without having full mime message MIME类型文件(无.aspx文件)的ASP.NET基本身份验证 - ASP.NET Basic Authentication for MIME Type files (None .aspx files) EventSource 的响应具有不是“text/event-stream”的 MIME 类型(“text/plain”)。 中止连接 Azure SignalR - EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection Azure SignalR
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM