我可以设置一个IIS MIME类型.NET? [英] Can I setup an IIS MIME type in .NET?

查看:239
本文介绍了我可以设置一个IIS MIME类型.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以设置自定义MIME类型通过ASP.NET或某些.NET code?我需要在IIS 6中注册的Silverlight XAML和XAP MIME类型。

Can I setup a custom MIME type through ASP.NET or some .NET code? I need to register the Silverlight XAML and XAP MIME types in IIS 6.

推荐答案

要添加到主MIME类型列表:

To add to the master mime type list:

using (DirectoryEntry mimeMap = new DirectoryEntry("IIS://Localhost/MimeMap"))
{
    PropertyValueCollection propValues = mimeMap.Properties["MimeMap"];

    IISOle.MimeMapClass newMimeType = new IISOle.MimeMapClass();
    newMimeType.Extension = extension; // string - .xap
    newMimeType.MimeType = mimeType;   // string - application/x-silverlight-app

    propValues.Add(newMimeType);
    mimeMap.CommitChanges();
}

添加引用:

在.NET'的System.DirectoryServices添加引用标签
在COM活动DS IIS命名空间提供者引用添加标签。

'System.DirectoryServices' on the .NET add references tab
'Active DS IIS Namespace Provider' on the COM add references tab.

要为特定网站配置MIME类型,改变..

To configure a mime type for a specific site, change ..

IIS://本地主机/ MimeMap

IIS://本地主机/ SVC / [iisnumber] /根

...替换'[iisnumber] 与该网站的IISNumber。

...replacing '[iisnumber]' with the IISNumber of the website.

这篇关于我可以设置一个IIS MIME类型.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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