I am excluding some of the ipaddress sending mail from my application.Here i created the custom tags in web.config file
<configSections>
<sectionGroup name="ExcludeIPAddressListSectionGroup">
<section name="IPAddressListSection" type="CustomConfigurationHandler.CustomConfiguration, CustomConfigurationHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" allowLocation="true" allowDefinition="Everywhere"/>
</sectionGroup>
</configSections>
<ExcludeIPAddressListSectionGroup>
<IPAddressListSection>
<ExcludedList1 Range="StartingIP=192.168.185.1; EndingIP=192.168.185.50" ></ExcludedList1>
<ExcludedList2 Range="StartingIP=192.168.185.51;EndingIP=192.168.185.51" ></ExcludedList2>
</IPAddressListSection>
</ExcludeIPAddressListSectionGroup>
I had created the section ExcludeIPAddressListSectionGroup and given range to exclude those ips
Am reading the custom tags from web.config like this
Hashtable config = (Hashtable)ConfigurationManager.GetSection("ExcludeIPAddressListSectionGroup/IPAddressListSection");
foreach (DictionaryEntry deKey in config)
{
Hashtable attribs = (Hashtable)deKey.Value;
foreach (DictionaryEntry deAttrib in attribs)
{
string range = deAttrib.Value.ToString();
string[] range_arr = range.Split(';');
foreach (string range_str in range_arr)
{
Response.Write(range_str+"<br>");
}
}
}
I need to format the string and pass startingip and ending ip to this function bool Between(long value, long left, long right)