C# IIS6下动态添加MIME类型

public static void AddMIMEType()
{
    DirectoryEntry rootEntry = GetDirectoryEntry("IIS://localhost/w3svc/1/root");
    foreach(PropertyValueCollection pc in rootEntry.Properties)
    {
        Console.WriteLine(pc.PropertyName+":"+pc.Value);
    }
    //rootEntry.Properties["MimeMap"].Add(
    IISOle.MimeMapClass _NewMime = new IISOle.MimeMapClass();          //新建MIME类型
    _NewMime.Extension = ".xap";
    _NewMime.MimeType = ".xap";
    rootEntry.Properties["MimeMap"].Add(_NewMime);  //添加MIME类型

    rootEntry.CommitChanges();//更改目录

}

posted on 2012-10-29 16:00  航甫  阅读(458)  评论(0编辑  收藏  举报

导航