zoukankan      html  css  js  c++  java
  • C#设置iis默认文档

     1 void Main()
     2 {
     3     using (ServerManager serverManager = new ServerManager())
     4     {
     5         var config = serverManager.GetWebConfiguration("SGSM");
     6         ConfigurationSection defaultDocumentSection = config.GetSection("system.webServer/defaultDocument");
     7         defaultDocumentSection["enabled"] = true;
     8         ConfigurationElementCollection filesCollection = defaultDocumentSection.GetCollection("files");
     9         ConfigurationElement addElement = filesCollection.CreateElement("add");
    10         addElement["value"] = @"myhome.html";
    11         filesCollection.AddAt(0, addElement);
    12 
    13         serverManager.CommitChanges();
    14     }
    15 
    16     using (ServerManager serverManager = new ServerManager())
    17     {
    18         var webConfig = serverManager.GetWebConfiguration("SGSM");
    19         var section = webConfig.GetSection("system.webServer/defaultDocument");
    20 
    21         foreach (ConfigurationElement item in section.GetCollection("files"))
    22         {
    23             var x = item["value"];
    24             Console.WriteLine(x);
    25         }
    26     }
    27 }
    28 
    29 // Define other methods and classes here
  • 相关阅读:
    KVC
    MRC&ARC
    网络基础
    沙盒
    GCD深入了解
    iOS 架构模式MVVM
    iOS 源代码管理工具之SVN
    iOS给UIimage添加圆角的两种方式
    Objective-C 中,atomic原子性一定是安全的吗?
    iOS Block循环引用
  • 原文地址:https://www.cnblogs.com/Shaina/p/14251466.html
Copyright © 2011-2022 走看看