LastBye
LastBye

Reputation: 1173

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 ?

Upvotes: 1

Views: 7418

Answers (4)

Andrew Hare
Andrew Hare

Reputation: 351466

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>

Upvotes: 3

Zhaph - Ben Duguid
Zhaph - Ben Duguid

Reputation: 26956

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.

Upvotes: 4

Ian Jacobs
Ian Jacobs

Reputation: 5501

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?

Upvotes: 5

Jay S
Jay S

Reputation: 7994

I have not been able to find a solution to this other than to move both applications into subfolders and ensure the parent folder has no Web.config.

Upvotes: 0

Related Questions