C#中操作IIS 7.0
2009-03-25 08:20:35 来源:WEB开发网删除应用程序池。
DeletePool
/// <summary>
/// Delete an existent web site app pool.
/// </summary>
/// <param name="appPoolName">App pool name for deletion.</param>
public static void DeletePool(string appPoolName)
{
using (ServerManager mgr = new ServerManager())
{
ApplicationPool pool = mgr.ApplicationPools[appPoolName];
if (pool != null)
{
mgr.ApplicationPools.Remove(pool);
mgr.CommitChanges();
}
}
}
在站点上添加默认文档。
AddDefaultDocument
public static void AddDefaultDocument(string siteName, string defaultDocName)
{
using (ServerManager mgr = new ServerManager())
{
Configuration cfg = mgr.GetWebConfiguration(siteName);
ConfigurationSection defaultDocumentSection = cfg.GetSection("system.webServer/defaultDocument");
ConfigurationElement filesElement = defaultDocumentSection.GetChildElement("files");
ConfigurationElementCollection filesCollection = filesElement.GetCollection();
foreach (ConfigurationElement elt in filesCollection)
{
if (elt.Attributes["value"].Value.ToString() == defaultDocName)
{
return;
}
}
try
{
ConfigurationElement docElement = filesCollection.CreateElement();
docElement.SetAttributeValue("value", defaultDocName);
filesCollection.Add(docElement);
}
catch (Exception) { } //this will fail if existing
mgr.CommitChanges();
}
}
- ››IIS7 Request format is unrecognized.
- ››IIS Rewrite 配置
- ››IIS7错误:“由于扩展配置问题而无法提供您请求的...
- ››IIS7应用PHP Manager使用FastCGI快速部署
- ››IIS短文件和文件夹泄漏漏洞的分析
- ››IIS .net 网站打不开 http:404 出错
- ››IIS上asp.net网站无法访问(错误:服务器应用程序不...
- ››IIS+PHP配置图文详解
- ››IIS7 下日期显示格式的解决办法
- ››IIS6下部署ASP.NET MVC应用程序
- ››操作系统资源不足两种方案解决办法
- ››IIS 6 下配置以 FastCGI 跑 PHP
更多精彩
赞助商链接