简体   繁体   中英

Sub Folder is affected by root web.config

It should be an easy question ,

I am building a site under IIS , For one part of it inside a subdirectory like \\blog I turned it to a vitual directory .

the root folder has its own web.config and the blog sub Folder has its own .

in the root's web.config I used :

<pages theme="DefaultTheme">

and the sub folder seems to be affected by that , it causes an error telling I don't have this theme .

What is the solution ?

Look into the:

<location> ... </location>

elements that can be loaded into the web.config. Not everything will work under it, but you might be able to override the subfolder to have no theme. Either that or maybe you can restrict the theme to only the top level folder with those tags?

Web.Config's can be nested, and so the pages element will affect all other applications below it in scope (for example, there is a web.config that sets up various defaults in the framework's config folder).

If you don't want the theme on the pages in your blog folder, have you tried setting the theme to an empty string in the sub web.config? This is a valid value for the attribute, and should override the one set in the parent.

Theming works by looking in the Themes folder under the application root - in this case, under the /blogs folder, and if it can't find one in there, it will throw this exception.

You want to add

<clear/>

to the subfolder's web.config. This will clear the parent configs values from whatever section you put clear into . For instance if you wanted to clear any connection strings from a parent config file you would do this:

<connectionStrings>
    <clear/>
    <!-- add new connection strings here -->
</connectionStrings>

除了将两个应用程序都移动到子文件夹并确保父文件夹没有Web.config之外,我无法找到解决方案。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM