本文介绍了从配置中的特定位置路径获取maxRequestLength值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为不同的位置路径设置了几个不同的maxRequestLengths.如何获取要查找的特定位置路径的值?

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:

推荐答案

检查一下

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

这篇关于从配置中的特定位置路径获取maxRequestLength值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 19:27