Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

Web.Config, Custom Section!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
- 30 Oct 2004 22:53 GMT
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
- 01 Nov 2004 06:59 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.