. Net (do not inherit)

Source: Internet
Author: User
Tags connectionstrings
Transferred from: forbidden (inheritance prohibited)

00:01:18 | category: DOTNET | Tag: Technology | font size, small/medium subscription

There are multiple WEB. CONFIG files in the website subdirectory, and the connection strings have the same names, which may conflict with each other.

<Location path = "." allowOverride = "true" inheritInChildApplications = "false">
<ConnectionStrings>
<Add name = "ddConnectionString" connectionString = "Data Source = 127.0.0.1; Initial Catalog = test; User

ID = sa; Password = bb "/>

</ConnectionStrings>
</Location>

 

Network Information:

Disable the virtual directory to inherit from some webconfig settings in the root directory.
The website uses url rewriting, but does not want the following sub-sites to be affected by Url rewriting, and does not want to change or reconfigure these sub-sites (virtual directory creation ),
There are two affected aspects:
1. Add the corresponding url rewriting component to the bin directory of the sub-station.
2. the url address of the sub-site is affected by the rewrite configuration of the root directory url.
Currently, only the. dll file that can be rewritten by the url can be copied to the bin directory under the sub-station, and then added to the web. config file of the corresponding sub-station.
<System. web>
<! -- Add -->
<HttpModules>
<Clear/>
</HttpModules>
<! -- Add -->
This method still has many disadvantages. You need to copy related. dll files.
Of course, you do not need to modify any information about the sub-site. The following introduces another method:
1. If it is an asp. net1.1 program, change asp.net configured in IIS to 2.0 (1.1 can be run under. net2.0 without affecting the normal operation of the original program)
2. Add
<Location path = "." allowOverride = "false" inheritInChildApplications = "false">
........
</Location>
Path does not need to specify a directory.
AllowOverride indicates whether this rewrite can be performed.
InheritInChildApplications indicates whether to inherit quilt-level applications.
Note: Because the inheritInChildApplications attribute is not found in asp. net1.1, 1. It is set for the currently modified configuration.
Specific Application Example: web. config in the root directory:
Example 1:
<Location path = "." allowOverride = "false" inheritInChildApplications = "false">
<System. web>
<HttpHandlers>
<Add verb = "POST, GET" path = "ajax/*. ashx" type = "Ajax. PageHandlerFactory, Ajax"/>
</HttpHandlers>
</System. web>
</Location>
Example 2:
<Location path = "." allowOverride = "true" inheritInChildApplications = "false">
<System. web>
<HttpModules>
<Add name = "UrlRewriteModule"
Type = "UrlRewritingNet. Web. UrlRewriteModule, UrlRewritingNet. UrlRewriter"/>
</HttpModules>
</System. web>
</Location>
Note: The above configuration will not apply to the web in the virtual directory. config inherits the web. config is incorrect. (Note: IIS is required. the configuration of net2.0 is required. This is not specified in many documents on the Internet)
Summary:
1. The site must be in the. net2.0 environment.
2. Use <location path = "." allowOverride = "true" inheritInChildApplications = "false"> </location> to limit some inheritance of web. config in the root directory.

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.