PC Review


Reply
Thread Tools Rate Thread

Can I add my own section to the web.config ?

 
 
craigkenisston@hotmail.com
Guest
Posts: n/a
 
      23rd Sep 2006
I need to store a few keys in the web.config file, so I was thinking to
add my own section like:

<MySection>
<MySection1 key1="blahblah" key2="asdf" />
<MySection2 key1="qwer" key2="zxcv" />
</MySection>

But wherever I place this, I get an error of "Unrecognized
configuration section".

Is it possible or not ?

 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      23rd Sep 2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>I need to store a few keys in the web.config file, so I was thinking to
> add my own section like:
>
> <MySection>
> <MySection1 key1="blahblah" key2="asdf" />
> <MySection2 key1="qwer" key2="zxcv" />
> </MySection>
>
> But wherever I place this, I get an error of "Unrecognized
> configuration section".
>
> Is it possible or not ?


I don't think so...

What possible value would this add anyway? Store your keys in
<appSettings> - that's what it's for...


 
Reply With Quote
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      23rd Sep 2006
Sure can. You can create your own configuration sections and groups. Look at
the configSections element for the web.config file in the docs.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I need to store a few keys in the web.config file, so I was thinking to
> add my own section like:
>
> <MySection>
> <MySection1 key1="blahblah" key2="asdf" />
> <MySection2 key1="qwer" key2="zxcv" />
> </MySection>
>
> But wherever I place this, I get an error of "Unrecognized
> configuration section".
>
> Is it possible or not ?
>



 
Reply With Quote
 
craigkenisston@hotmail.com
Guest
Posts: n/a
 
      24th Sep 2006

Ok, I get it.
Either I put everything inside the appSettings section, or I use the
configSettings sections to declare my own sections and then put
everything in there.

Thanks a lot !

 
Reply With Quote
 
Laurent Bugnion
Guest
Posts: n/a
 
      24th Sep 2006
Hi,

Mark Rae wrote:
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>
>>I need to store a few keys in the web.config file, so I was thinking to
>>add my own section like:
>>
>><MySection>
>><MySection1 key1="blahblah" key2="asdf" />
>><MySection2 key1="qwer" key2="zxcv" />
>></MySection>
>>
>>But wherever I place this, I get an error of "Unrecognized
>>configuration section".
>>
>>Is it possible or not ?

>
>
> I don't think so...


Yes, it is. See Mark's reply in this thread.

> What possible value would this add anyway? Store your keys in
> <appSettings> - that's what it's for...


appSettings only allows key-value pairs. That's only sufficient for
limited settings. If you need something more solid, you need to define
your own schema.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      24th Sep 2006
re:
> If you need something more solid, you need to define your own schema.


Maybe not quite as much as "define your own schema",
but you'd need to write your own configuration section handler.

See :
http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx
....for ASP.NET 2.0

and:
http://msdn2.microsoft.com/en-us/library/ms228056.aspx
....for ASP.NET 1.1.

There's more examples and explanations, for 1.1, at:
http://msdn.microsoft.com/library/de...et04222003.asp




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Laurent Bugnion" <galasoft-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Mark Rae wrote:
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>
>>
>>>I need to store a few keys in the web.config file, so I was thinking to
>>>add my own section like:
>>>
>>><MySection>
>>><MySection1 key1="blahblah" key2="asdf" />
>>><MySection2 key1="qwer" key2="zxcv" />
>>></MySection>
>>>
>>>But wherever I place this, I get an error of "Unrecognized
>>>configuration section".
>>>
>>>Is it possible or not ?

>>
>>
>> I don't think so...

>
> Yes, it is. See Mark's reply in this thread.
>
>> What possible value would this add anyway? Store your keys in <appSettings> - that's what it's
>> for...

>
> appSettings only allows key-value pairs. That's only sufficient for limited settings. If you need
> something more solid, you need to define your own schema.
>
> HTH,
> Laurent
> --
> Laurent Bugnion, GalaSoft
> Software engineering: http://www.galasoft-LB.ch
> PhotoAlbum: http://www.galasoft-LB.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch



 
Reply With Quote
 
Laurent Bugnion
Guest
Posts: n/a
 
      24th Sep 2006
Hi,

Juan T. Llibre wrote:
> re:
>
>>If you need something more solid, you need to define your own schema.

>
>
> Maybe not quite as much as "define your own schema",
> but you'd need to write your own configuration section handler.


Maybe I expressed myself wrongly. What I meant is that you can add your
own config sections, including self-defined XML nodes, for example (from
the MSDN doc)

<myCustomGroup>
<myCustomSection myAttrib1="Clowns">
<myChildSection
myChildAttrib1="Zippy"
myChildAttrib2="Michael Zawondy "/>
</myCustomSection>
</myCustomGroup>

This is what I mean with "your own schema".

HTH,
Laurent

> See :
> http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx
> ...for ASP.NET 2.0
>
> and:
> http://msdn2.microsoft.com/en-us/library/ms228056.aspx
> ...for ASP.NET 1.1.
>
> There's more examples and explanations, for 1.1, at:
> http://msdn.microsoft.com/library/de...et04222003.asp

--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      24th Sep 2006
"Laurent Bugnion" <galasoft-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>> What possible value would this add anyway? Store your keys in
>> <appSettings> - that's what it's for...

>
> appSettings only allows key-value pairs. That's only sufficient for
> limited settings. If you need something more solid, you need to define
> your own schema.


Apologies, group - I didn't read the OP carefully enough...


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      24th Sep 2006
re:
> This is what I mean with "your own schema".


heh, heh...

I knew you meant that.

Just wanted to make sure readers didn't take the word "schema" literally,
plus, also, point to documentation where instructions can be found.

;-)



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Laurent Bugnion" <galasoft-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Juan T. Llibre wrote:
>> re:
>>
>>>If you need something more solid, you need to define your own schema.

>>
>>
>> Maybe not quite as much as "define your own schema",
>> but you'd need to write your own configuration section handler.

>
> Maybe I expressed myself wrongly. What I meant is that you can add your own config sections,
> including self-defined XML nodes, for example (from the MSDN doc)
>
> <myCustomGroup>
> <myCustomSection myAttrib1="Clowns">
> <myChildSection
> myChildAttrib1="Zippy"
> myChildAttrib2="Michael Zawondy "/>
> </myCustomSection>
> </myCustomGroup>
>
> This is what I mean with "your own schema".
>
> HTH,
> Laurent
>
>> See :
>> http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx
>> ...for ASP.NET 2.0
>>
>> and:
>> http://msdn2.microsoft.com/en-us/library/ms228056.aspx
>> ...for ASP.NET 1.1.
>>
>> There's more examples and explanations, for 1.1, at:
>> http://msdn.microsoft.com/library/de...et04222003.asp

> --
> Laurent Bugnion, GalaSoft
> Software engineering: http://www.galasoft-LB.ch
> PhotoAlbum: http://www.galasoft-LB.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: web.config credentials section Allen Chen [MSFT] Microsoft ASP .NET 0 5th May 2009 03:47 AM
Get Web.Config section shapper Microsoft ASP .NET 1 23rd Jun 2007 12:19 AM
reading web.config section alf Microsoft ASP .NET 5 1st Mar 2007 04:41 PM
Custom section in web.config =?Utf-8?B?VGFiaQ==?= Microsoft ASP .NET 6 18th Nov 2005 04:33 PM
more values in one section of app.config Patrick Microsoft C# .NET 3 6th Oct 2003 01:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:11 PM.