views:

1777

answers:

4

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 ?

A: 

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.

Jay S
+3  A: 

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?

Ian Jacobs
the answers all should be correct ,can you give me an example about the solution you told in this issuethanks
Sypress
http://diablopup.blogspot.com/2007/05/overriding-webconfig-using-tag.html is one good example that illustrates what I'm talking about.
Ian Jacobs
Wow, I did not know you could do that - cool.
Zhaph - Ben Duguid
Yeah you can do some nifty stuff. Not everything works though.
Ian Jacobs
It should be a good solution , I'll try it , Many thanks
Sypress
+3  A: 

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.

Zhaph - Ben Duguid
thanks , Ill try it , it should work
Sypress
+3  A: 

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>
Andrew Hare
Unfortunately It gave me errors that cant understand this clear element
Sypress
@Sypress: Did you have <clear/> **inside** the <connectionStrings> section? i initially, mistakenly, had it just before the opening **connectionStrings** element and i got the error "Unrecognized configuration section clear."
Ian Boyd