Get maxRequestLength value from specific location path in config

有些话、适合烂在心里 提交于 2020-01-06 20:17:09

问题


I have several different maxRequestLengths set for different location paths. How do I get the value of the specific location path that I am looking for?

Here is what is in config:


回答1:


Check this out

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



来源:https://stackoverflow.com/questions/34093968/get-maxrequestlength-value-from-specific-location-path-in-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!