使用了2个配置文件 [英] Used 2 config file

查看:124
本文介绍了使用了2个配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在asp.net项目中使用2个配置文件(一个用于主要配置,另一个用于验证).
请告诉我如何在项目中使用2个文件?
谢谢.

I need to use 2 config files in an asp.net project (one for main configuration and other for validation).
Please tell me how to use 2 files in project?
Thanks.

推荐答案

您可以根据需要使用任意数量的配置文件.但是只能有一个web.config文件.

顺便问一下,您想要什么样的配置和验证?

最简单的方法是创建配置文件(所需的任何xml结构)并将其读取为XmlDocument.
You can use as many config files as you want. But there can be one and only one web.config file.

By the way, what kind of configuration and validations do you want to have?

The simplest way would be to create the config file(any xml structure you want) and read it as a XmlDocument.


Web.config对于每个虚拟目录都应该只有一个.即使将多个web.config放在一个文件夹中,ConfigurationManager也会仅解析文件Web.config.其他则需要手动阅读.

除此之外,您可以在Web应用程序中创建的每个文件夹中放置1个web.config,并且Web服务器将仅解析本地web.config(如果找不到,则用于父级).

因此,如果您有一个拥有自己的web.config文件的abcd文件夹,则它不会解析基本的web.config来查找对该虚拟目录中的表单进行的调用.

:)
Web.config should be only one for each virtual directory. Even if you place multiple web.config in one folder, ConfigurationManager will only parse the file Web.config. Others you need to read it manually.

Other than that, you can place 1 web.config in each folder you create in the web application and the web server will only parse the local web.config(If not found it goes for the parent).

Therefore, if you have a folder abcd which have its own web.config file, it wouldnt go to parse the base web.config for calls made for forms inside that virtual directory.

:)


这篇关于使用了2个配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆