中国站长下载-为中国站长提供最好最全的建站资源! 首 页发布资源有事留言繁體中文
设为首页
加入收藏
联系我们
 
您当前的位置:中国站长下载 -> 文章中心 -> 网页编程 -> .NET编程 -> 文章内容  虚拟主机 域名注册 退出登录 用户管理
栏目导航
· ASP编程 · .NET编程
· PHP编程 · JSP编程
· CGI 专区
热门文章
· sndvol32 - sndvol3...
· [组图] FLASH:《大话李白》...
· 个人网站到底能赚多...
· [图文] Rundll.exe是病毒吗...
· [组图] Flash:制作MV
· 价值12万元的网站SE...
· 网站创业者,你需要...
· 一个成功的网站设计...
· [图文] FLASH:韩国导航条解...
· 中国网站的赚钱模式...
相关文章
· [图文] 用ASP.NET 2.0设计网...
· [图文] 用ASP.NET 2.0设计网...
· [图文] 用ASP.NET 2.0设计网...
· [图文] 用ASP.NET 2.0设计网...
· [图文] 用ASP.NET 2.0设计网...
· ASP.NET中WebForm组...
· ASP.NET中WebForm组...
· ASP.NET中WebForm组...
· ASP.NET中WebForm组...
· ASP.NET计数器
ASP.NET虚拟主机安全漏洞解决方案(3)
作者:不详  来源:不详  发布时间:2006-8-14 9:31:54  发布人:chinazhan

 减小字体 增大字体

     操作iis应用程序池
  
  using System;
  using System.DirectoryServices;
  using System.Reflection;
  
  namespace ADSI1
  {
   ///
   /// Small class containing methods to configure IIS.
   ///
   class ConfigIIS
   {
    ///
    /// The main entry point for the application.
    ///
    [STAThread]
    //主程序入口,可以选择用哪些,我为了方便,全部功能都写上去了。
    static void Main(string[] args)
    {
     string AppPoolName = "MyAppPool";
     string newvdir1 = "MyVDir";
     DirectoryEntry newvdir = CreateVDir(newvdir1);
  
     CreateAppPool(AppPoolName);
     AssignAppPool(newvdir, AppPoolName);
  
     ConfigAppPool("Stop",AppPoolName);
    }
  
    //创建虚拟目录
    static DirectoryEntry CreateVDir (string vdirname)
    {
     DirectoryEntry newvdir;
     DirectoryEntry root=new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
     newvdir=root.Children.Add(vdirname, "IIsWebVirtualDir");
     newvdir.Properties["Path"][0]= "c:\\inetpub\\wwwroot";
     newvdir.Properties["AccessScript"][0] = true;
     newvdir.CommitChanges();
     return newvdir;
    }
  
    //创建新的应用程序池。
    static void CreateAppPool(string AppPoolName)
    {
     DirectoryEntry newpool;
     DirectoryEntry apppools=new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
     newpool=apppools.Children.Add(AppPoolName, "IISAPplicationPool");
     newpool.CommitChanges();
    }
  
    static void AssignAppPool(DirectoryEntry newvdir, string AppPoolName)
    {
     object[] param={0, AppPoolName, true};
     newvdir.Invoke("AppCreate3", param);
    }
  
    //method是管理应用程序池的方法,有三种Start、Stop、Recycle,而AppPoolName是应用程序池名称
    static void ConfigAppPool(string method,string AppPoolName)
    {
     DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
     DirectoryEntry findPool = appPool.Children.Find(AppPoolName,IIsApplicationPool");
     findPool.Invoke(method,null);
     appPool.CommitChanges();
     appPool.Close();
    }
  
    //应用程序池的列表
    static void AppPoolList()
    {
     DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
     foreach(DirectoryEntry a in appPool.Children)
     {
      Console.WriteLine(a.Name);
     }
    }
  
    private void VDirToAppPool()
    {
     DirectroryEntry VD = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT/ccc");
     Console.WriteLine(VD.Properties["AppPoolId"].Value.ToString());
    }
   }
  }
  
  
  
  
    做人要厚道,请注明转自chinazhan中国站长(www.ChinaZhan.com)。

 
[] [返回上一页] [打 印] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
中国站长下载
中国站长下载

本页只接受PR>=4 IT类站点连接,申请连接,谢谢您们的支持!希望我们的下载站能够真正帮到中国的站长们!
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图
Copyright © 2005-2006 ChinaZhan.Net. All Rights Reserved .