【问题标题】:Get maxRequestLength value from specific location path in config从配置中的特定位置路径获取 maxRequestLength 值
【发布时间】:2015-12-04 17:21:51
【问题描述】:

我为不同的位置路径设置了几个不同的 maxRequestLengths。如何获取我正在寻找的特定位置路径的值?

这是配置中的内容:

【问题讨论】:

    标签: config maxrequestlength


    【解决方案1】:

    看看这个

    using System;
    using System.Collections;
    using System.Configuration;
    
    class DisplayLocationInfo
    {
        static void Main(string[] args)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConfigurationLocationCollection myLocationCollection = config.Locations;
            foreach (ConfigurationLocation myLocation in myLocationCollection)
            {
                Console.WriteLine("Location Path: {0}", myLocation.Path);
                Configuration myLocationConfiguration = myLocation.OpenConfiguration();
                Console.WriteLine("Location Configuration File Path: {0}", myLocationConfiguration.FilePath);
            }
            Console.WriteLine("Done...");
            Console.ReadLine();
        }
    }
    

    https://msdn.microsoft.com/en-us/library/system.configuration.configurationlocation(v=vs.100).aspx

    【讨论】:

    • 当我点击第一个 OpenExeConfiguration 我得到错误: exePath must be specified when not running in a Standalone exe The application is .NET 4.0
    • 另外,使用 web.config
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-08
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 2017-04-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多