views:

134

answers:

1

I have broken down the horribly unwieldy web.config file into individual files for some of the sections (e.g. connectionStrings, authentication, pages etc.) using the configSource attribute.

This is working fine, but the individual xml files that hold the section 'snippets' cause warnings in VS.

For example, a file named roleManager.config is used for the role manager section, and looks like this:

<roleManager enabled="false">
</rolemanager>

However I get a blue squiggle under the roleManager element in VS, and the following warning: The 'roleManager' element is not declared

I guess this is something to do with valid xml and schemas etc. Is there an easy way to fix this? Something I can add to the individual files?

Thanks

P.S. I have heard that it is bad practice to break the web.config file out like this. But don't really understand why - can anyone illuminate me?

+1  A: 

Hi,
I think that you get the blue squiggles since the schema of your web.config file doesn't declare these custom config sections that you've 'broken out' into individual files.

In investigating this, I see that some of my solutions have the same issue, but the config sections that are provided from microsoft DON'T have the squiggles. eg: we have extracted the appsettings and connectionstrings out into their own files, and they don't get the squiggles, but our custom ones do.

I tried to view the microsoft schema at schemas.microsoft.com/.netconfiguration/v2.0, but I get a 404 when trying to download it.

What I'm trying to say is if you get a copy of the MS schema and alter it to include your external config files, you should be able to get rid of the dreaded squiggles!

HTH, Lance

Lanceomagnifico
Thanks lance I'll look into that. I've noticed something similar with some sections not causing problems. It seems to me that sections which are directly under the <configuration> (root) element do not have a problem (such as connectionstrings), while the ones that are one level down from the root (such as roleManager, which is under <configuration><system.web> do have problems.
UpTheCreek