zoukankan      html  css  js  c++  java
  • C# 增加 IIS 默认主页文档

    void Main()
    {
        using (ServerManager serverManager = new ServerManager())
        {
            var config = serverManager.GetWebConfiguration("SGSM");
            ConfigurationSection defaultDocumentSection = config.GetSection("system.webServer/defaultDocument");
            defaultDocumentSection["enabled"] = true;
            ConfigurationElementCollection filesCollection = defaultDocumentSection.GetCollection("files");
            ConfigurationElement addElement = filesCollection.CreateElement("add");
            addElement["value"] = @"myhome.html";
            filesCollection.AddAt(0, addElement);
    
            serverManager.CommitChanges();
        }
    
        using (ServerManager serverManager = new ServerManager())
        {
            var webConfig = serverManager.GetWebConfiguration("SGSM");
            var section = webConfig.GetSection("system.webServer/defaultDocument");
    
            foreach (ConfigurationElement item in section.GetCollection("files"))
            {
                var x = item["value"];
                Console.WriteLine(x);
            }
        }
    }
    
    // Define other methods and classes here
  • 相关阅读:
    win中使用curl上传文件报错
    S2-052
    S2-048
    S2-045、S2-046
    S2-033、S2-037
    S2-032
    S2-029
    day12-python之深灰魔法
    day10-11-python基础之字符串
    day09-python基础
  • 原文地址:https://www.cnblogs.com/nanfei/p/13953288.html
Copyright © 2011-2022 走看看