I designa config file, says my.config, separated from web.config for not cluttering web.config. I hope that I can still use Configure Class to aceess the
my.config, instead of using low-level XML API to parse it!
Is this scenario possible to implement?
Any suggestion is welcome.
Ricky.
Take nothing on looks; take everything on evidence.
- Charles Dickens
First, don't do this. The web.config is designed to be "cluttered" with your settings. Use comments in it iof you wish to organize it. That said, you can reference external files if you wish:
For the specific config section as you provided, we need to create corresponding configuration section handler for it. Please refer to following link to learn how to create a custom configuration section handler for your own configuration section.
Sincerely,
Benson Yu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
I would also be really interested in such a solution. I already have custom sections in web.config loading settings into the web application via Configuration Section Handlers, now I would like to move the xml configuration into a separate file. Has anyone
achieved this? It seems like the file/configSource attribute only exists for the inbuilt config sections such as appSettings etc...?
aliasncnu
Member
146 Points
333 Posts
How to use Configure class to access "my own" configuration file
Apr 28, 2008 09:48 AM|LINK
Hi,
I designa config file, says my.config, separated from web.config for not cluttering web.config. I hope that I can still use Configure Class to aceess the my.config, instead of using low-level XML API to parse it!
Is this scenario possible to implement?
Any suggestion is welcome.
Ricky.
- Charles Dickens
jeff@zina.co...
All-Star
87677 Points
11637 Posts
Moderator
Re: How to use Configure class to access "my own" configuration file
Apr 28, 2008 12:34 PM|LINK
First, don't do this. The web.config is designed to be "cluttered" with your settings. Use comments in it iof you wish to organize it. That said, you can reference external files if you wish:
http://www.devx.com/vb2themax/Tip/18880
http://www.beansoftware.com/ASP.NET-Tutorials/Multiple-Config.aspx
Jeff
aliasncnu
Member
146 Points
333 Posts
Re: How to use Configure class to access "my own" configuration file
Apr 28, 2008 01:42 PM|LINK
Hello, the external appSettings is not perfectly suitable for my situation. I will define hierarchial structure as
<a>
<b name="..." friendlay="..." value="..." />
<b name="..." friendlay="..." value="..." />
</a>
Do you know any more complex mechanism to access this kind of xml with objects armed with strong-typed properties like Configuration class?
Regards,
Ricky.
- Charles Dickens
Benson Yu - ...
All-Star
34797 Points
2497 Posts
Re: How to use Configure class to access "my own" configuration file
May 04, 2008 03:30 AM|LINK
Hi Ricky,
For the specific config section as you provided, we need to create corresponding configuration section handler for it. Please refer to following link to learn how to create a custom configuration section handler for your own configuration section.
How To Create a Custom ASP.NET Configuration Section Handler in Visual C# .NET
http://support.microsoft.com/kb/309045
Benson Yu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
aliasncnu
Member
146 Points
333 Posts
Re: How to use Configure class to access "my own" configuration file
May 05, 2008 12:38 AM|LINK
Hi,
I have read similar topic you provided. Do you know how to extend this mechanism to my own config file instead of web.config?
Thanks,
Ricky.
- Charles Dickens
Wulfy
Member
88 Points
27 Posts
Re: How to use Configure class to access "my own" configuration file
May 07, 2008 11:30 AM|LINK
I would also be really interested in such a solution. I already have custom sections in web.config loading settings into the web application via Configuration Section Handlers, now I would like to move the xml configuration into a separate file. Has anyone achieved this? It seems like the file/configSource attribute only exists for the inbuilt config sections such as appSettings etc...?
Thanks
James
aliasncnu
Member
146 Points
333 Posts
Re: How to use Configure class to access "my own" configuration file
May 09, 2008 01:35 AM|LINK
Hello, James
I have posted a workaround on http://www.codeproject.com/KB/aspnet/AddCustomConfigSections.aspx.
Hope it help! Regrads,
Ricky
- Charles Dickens