我排除一些ip地址從我application.Here發送郵件的我創建的自定義標籤從web.config中讀取和格式化字符串
<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>
我創造了部分ExcludeIPAddressListSectionGroup和web.config文件給定範圍內,以排除那些IPS
是從web.config中讀取自定義標籤這樣
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>");
}
}
}
我需要格式化字符串,並通過startingip和e發送ip到這個函數bool Between(long value,long left,long right)
我已經dited你的問題因爲web.config對用戶不可見plz檢查它 – Neel
你的問題是什麼? –