Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Can I add my own section to the web.config ?

Reply
Thread Tools

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

 
 
craigkenisston@hotmail.com
Guest
Posts: n/a
 
      09-23-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
 
      09-23-2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...

>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
 
      09-23-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) ps.com...
>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
 
      09-24-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
 
      09-24-2006
Hi,

Mark Rae wrote:
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ps.com...
>
>
>>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
 
      09-24-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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Mark Rae wrote:
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) ps.com...
>>
>>
>>>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
 
      09-24-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
 
      09-24-2006
"Laurent Bugnion" <(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
 
      09-24-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" <(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

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
Using own classloader inside J2EE to load and unload own classes. Stefan Siegl Java 1 07-02-2013 05:05 AM
section with in a section config file and reading that config file kampy Python 9 10-19-2012 10:59 PM
Win XP logon user icons - can you add your own pics for the different users? Lookout Computer Support 10 12-09-2006 08:29 PM
How can I add my own data to a Web.FormsAuthentication cookie? Rof ASP .Net 0 12-07-2005 02:13 PM
[RDOC] Creating my own section in a page Daniel Berger Ruby 2 10-31-2004 06:32 PM



Advertisments