How to make Webconfig in a virtual directory do not inherit site settings

Source: Internet
Author: User

A Web site under the Chinese redwood Network to build a virtual directory, the results of the virtual directory system will call the Chinese redwood Web. config on the Internet to find the following solutions

In the Web. config (such as the root directory) plus
such as: <location path= "." Allowoverride= "false" inheritinchildapplications= "false" > </location>
Here's how:
Program code
<location path= "." Allowoverride= "false" inheritinchildapplications= "false" >
<system.web>
<pages maintainscrollpositiononpostback= "true" >
</system.web >
</location>
So the next level of virtual directory will be able to meet your needs.

Here's another article:

=====================================================

Today to deploy a website and a web-related webservices interface, I put the Web interface as a virtual directory below it, so that they can share a domain name. They each have a webconfig configuration file, after deployment found that the site is normal, But the Web interface error, said the configuration file out of the problem, carefully check the discovery Web interface with the website configuration file, suddenly did not recruit.

Later on the Internet, found that the configuration section using the configuration file can let it not inherit the parent directory configuration file, as follows

<location path= "." Allowoverride= "false" inheritinchildapplications= "false" > </location>

Add it to the parent directory outside of the <system.web> section, test it is so, very happy, although remember to forget, at the same time also shared!

Here's the better one:

The Web. config in the virtual directory inherits the problem with Web. config in the home directory because the Web. config in the root directory was added HttpHandler, HttpModule.
Workaround: Add the HttpHandler HttpModule declaration to the location.
As shown below:
<location path= "." Allowoverride= "true" inheritinchildapplications= "false" >
<system.web>
<add name= "Urlrewritemodule"
Type= "UrlRewritingNet.Web.UrlRewriteModule, Urlrewritingnet.urlrewriter"/>
</system.web>
</location>

Path does not have to specify a directory
AllowOverride refers to whether this override can be overridden
InheritInChildApplications refers to whether a quilt-level application inherits
One, apply authentication, However, individual directories or files do not require authentication
The most common is the background of a Web site needs verification, and the front desk is not required, the general login page will have a verification code, and generate a verification code that the page does not need to verify, otherwise verify that the picture is not displayed.
Workaround:
<system.web>
<!--authentication-->
<authentication mode= "Forms";
<forms name=. MyForm "loginurl=" Login.aspx "timeout=" protection = "All"/>
</authentication>
<authorization
<deny users = "?" />
</authorization>
</system.web>
<!--verification code-->
<location path = "checkcode.aspx
<system.web;
<authorization;
<allow users = "*"/>
</authorization>
& Lt;/system.web>
</location> use authentication, prohibit anonymous user access, and checkcode.aspx the page to allow all users access, that is, no authentication.

Second, overwrite (not required) Web. config inheritance
Assume that there is a site A in IIS, and a site below a virtual directory B, you can enter: "TTP://IP/" access to the A site, enter the HTTP://IP address/b access to the B. website While the Web. config in Project B will inherit the Web. config of site A, if config for a has many settings such as A project uses the theme
<pages enableeventvalidation=" false "validaterequest=" false "theme = "Default" >b item does not have
<pages enableeventvalidation= "false" validaterequest= "false" Theme= "" > Let B's subject be empty, Otherwise, the B run-time prompt cannot find the default main topic;

Settings for

A
<add name= "Sitecache" type= "Sitecache"/>
<clear/>
<appsettings>
<add key= "app" value= ""/>
</appsettings>b runtime will prompt the app to load, at this point
<appsettings>
<remove Name= "App"/>,
<add key= "app" value= ""/>
</appSettings> or:
<appsettings>
< Clear/>
<add key= "app" value= ""/>
</appsettings>
Third, disable Web. config rewrite
With the above example, If the config setting in B must be the same as in a and cannot be overridden, then A's config setting
<location path= "B" allowoverride= "false";
<system.web>
<add name= "Sitecache" type= "Sitecache"/>
</ System.web>
</location> at this point, the config in B does not overwrite the

Web. config duplication for virtual directories and primary sites
2008-01-09 10:52
The Web. config of the virtual directory inherits the properties from the Web. config in the primary site, so for nodes such as Httphandler,httpmodule in the primary site, you should remove them from the virtual directory

For httphandlers, if processing of *.aspx is set in the parent Web. config, the child Web. config is reset as follows

<remove verb= "*" path= "*.aspx"/>
<add verb= "*" path= "*.aspx" type= "System.Web.UI.PageHandlerFactory"/>

I developed it using. NET 2.0. Got a friend's project on hand.
First, a website was developed with Web application. In the forum chose to use the net
Later found DZ out of the. NET 2.0 forum. Consider using this

But the problem came out, in the sub-virtual directory when the WEB.CONFG and most of the friends in the Forum encountered the problem of repetition
Successfully implemented WEB.CONFG integration after 3 hours of thinking

The first is the development of their own website webconfig unchanged.
DZ is added to the BBS as a virtual directory. At this time DZ's webconfig
The place to be modified is in the

<add type= "Discuz.Forum.HttpModule, Discuz.forum" name= "HttpModule"/>
<remove name= "Webbhttpmodule"/>
<remove verb= "*" path= "progress.ashx"/>

These two parts. Join your main site using the

This allows for integration. It's actually quite simple. The reason is that the two sections under the subdirectory inherit from the parent directory.

This approach is based on the ability to create multiple virtual directories.

If it is a leased server empty piece. Only one virtual directory can be created. I haven't tried it yet. I would like this to DZ developers to modify the

The reason for writing this post. is to find that many of the Buddies in the forum don't know how to solve this problem.

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.