I'm trying to store something like this in my web.config file:
<authInfoGroup>
<authInfo UserId="uid1" Passport="pwd1" Expiry="" />
<authInfo UserId="uid2" Passport="pwd2" Expiry="" />
</authInfoGroup>
To do so, I've created the following section in my web.config:
<configSections>
<sectionGroup name="authInfoGroup">
<section name="authInfo"
type="System.Configuration.SingleTagSectionHandler, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</sectionGroup>
</configSections>
However, this fails and here's the error desc.:
Sections must only appear once per config file. See the help topic
<location> for exceptions
However, I need to keep the above-mentioned data in my web.config file; and
obviously, there are always more than one authInfo that I'm going to keep.
Any idea?
Thanks in advance,
Mehdi
Scott M. - 31 Oct 2004 04:35 GMT
Change:
> <authInfoGroup>
> <authInfo UserId="uid1" Passport="pwd1" Expiry="" />
> <authInfo UserId="uid2" Passport="pwd2" Expiry="" />
> </authInfoGroup>
To:
<appSettings>
<add key="uid1" value="pwd1,"" />
<add key="uid2" value="pwd2,"" />
</appSettings>
Then, to retrieve the values in another file:
Dim UserInfo as string =
System.Configuration.ConfigurationSettings.AppSettings("uid1")
You could then use various string methods to parse the value for the
password and/or expiration.
> I'm trying to store something like this in my web.config file:
>
[quoted text clipped - 25 lines]
> Thanks in advance,
> Mehdi
This is the fast solution, but I need the one I described. Any idea?
> Change:
>
[quoted text clipped - 47 lines]
> > Thanks in advance,
> > Mehdi
Scott M. - 31 Oct 2004 17:47 GMT
I'm confused. Why do you "need" your solution, which doesn't work?
What is it about what I've showed you that won't work for you?
This is how you store user defined values in Web.Config and then retrieve
them.
> This is the fast solution, but I need the one I described. Any idea?
>
[quoted text clipped - 50 lines]
>> > Thanks in advance,
>> > Mehdi
MJ - 01 Nov 2004 10:25 GMT
Try
<authInfoGroup>
<authInfos>
<authInfo UserId="uid1" Passport="pwd1" Expiry="" />
<authInfo UserId="uid2" Passport="pwd2" Expiry="" />
</authInfos>
</authInfoGroup>
And
<configSections>
<sectionGroup name="authInfoGroup">
<section name="authInfos"
type="System.Configuration.SingleTagSectionHandler, System,
Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>
</sectionGroup>
</configSections>
The code in your class that implements IConfigurationSectionHandler
should then be able to move through the XmlNode.ChildNodes
collection inspecting each <authInfo>.
> I'm trying to store something like this in my web.config file:
>
[quoted text clipped - 24 lines]
> Thanks in advance,
> Mehdi
MJ - 01 Nov 2004 22:49 GMT
Missed the significance of SingleTagSectionHandler and had thought
your were writing your on implementation of
IConfigurationSectionHandler(which might be an idea?).
But try this setup
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="myCustomSection"
type="System.Configuration.SingleTagHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</configSections>
<myCustomSection mykey="myvalue" />
</configuration>
which comes from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/v
bnet04222003.asp
> Try
>
[quoted text clipped - 49 lines]
> > Thanks in advance,
> > Mehdi