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
  • 相关阅读:
    迪杰斯特拉_优先队列 模板
    POJ3268(Dijkstra_邻接矩阵)
    Uva-10815
    Uva-10474
    同余方程
    欧几里得算法与扩展欧几里得算法
    大整数型的加法
    Uva442
    《哲学起步》读后感 读书笔记
    《论大战略》读后感 读书笔记
  • 原文地址:https://www.cnblogs.com/Shaina/p/14251466.html
Copyright © 2011-2022 走看看