Set Web. config for Debug and Release respectively

Source: Internet
Author: User

Requirement: when developing an asp.net application, you often want to use different configurations in the debug and release environments, but the web. config file has only one

Solution: you can write the configuration in the debug environment in the original web. config, and then write the unique configuration in the release environment in web. release. config. Examples of common cases:

1. replace an attribute value of a node, and use "SetAttributes" to convert the value of "connectionString, the connectionString value of this node is used only when the "Match" Locator finds the value of "name" as "MyDB. Other attribute values that do not need to be changed are not required.


 

2. Replace the entire node. The "Replace" conversion replaces the entire <mermerrors> section of the web. config file. Note that because there is only one mermerrors section under the <system. web> node, the "xdt: Locator" feature is not required.


3. delete an attribute of a node and use RemoveAttributes. Delete the debug attribute of the compilation node.

 


The above tests are available.

Summary: through the web. release. config or web. debug. you can search for and replace node content in the specified format in config to implement web. config generates different versions based on different production environments to facilitate debugging and release.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.