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
  • 相关阅读:
    模板、中间件以及MVC与MTV
    Cookie与Session
    分页与网页攻击
    Django一对一查询,列类型及参数
    Django ORM 查询
    Django中ORM多对多表的操作
    Django中的ORM
    一、Vue简介
    三、路由层(urls.py)
    二、django简介
  • 原文地址:https://www.cnblogs.com/Shaina/p/14251466.html
Copyright © 2011-2022 走看看