Webconfig:
[Html]
<? Xml version = "1.0"?>
<! --
For more information about how to configure ASP. NET applications,
-->
<Configuration>
<ConfigSections>
<Section name = "RemotingObject" type = "RemotingObject"/>
</ConfigSections>
<System. web>
<Compilation debug = "true" targetFramework = "4.0"/>
</System. web>
<RemotingObject available = "true" pollTimeout = "00:01:00" location = "tcp: // OrderComputer: 8010/OrderService"/>
</Configuration>
Get custom node content:
[Csharp]
// Open the configuration file
Configuration config = WebConfigurationManager. OpenWebConfiguration ("~ /");
// Get the configuration section object
RemotingObject custSection =
(RemotingObject) config. GetSection ("RemotingObject ");
// Display configuration section information
LblInfo. Text + = "getting custom configuration section information... <br/>" +
"<B> Location: </B>" + custSection. Location +
"<Br/> <B> Available or not: </B>" + custSection. Available. ToString () +
"<Br/> <B> Timeout: </B>" + custSection. PollTimeout. ToString () + "<br/> ";
RemotingObject object class
[Csharp]
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Configuration;
/// <Summary>
/// Summary of RemotingObject
/// </Summary>
Public class RemotingObject: ConfigurationSection
{
// Define whether the remote object is available
[ConfigurationProperty ("available", IsRequired = false, DefaultValue = true)]
Public bool Available
{
Get {return (bool) base ["available"];}
Set {base ["available"] = value ;}
}
// Define the timeout time of the Remote Object
[ConfigurationProperty ("pollTimeout", IsRequired = true)]
Public TimeSpan PollTimeout
{
Get {return (TimeSpan) base ["pollTimeout"];}
Set {base ["pollTimeout"] = value ;}
}
// Define the location of the Remote Object
[ConfigurationProperty ("location", IsRequired = true)]
Public string Location
{
Get {return (string) base ["location"];}
Set {base ["location"] = value ;}
}
}