在web.config文件中添加ipaddress列表 [英] Add list of ipaddress in web.config file

查看:290
本文介绍了在web.config文件中添加ipaddress列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用web.config文件中的ipaddress列表验证用户ipaddress.

我使用安全标签添加ipaddress列表,如下所示

I want to validate the user ipaddress with the list of ipaddress in web.config file .

I add list of ipaddress using security tag as follow

<security>
      <ipsecurity allowunlisted="false">
        <!--blocks every one unless the ip address in list-->
        <clear />
        <add ipaddress="127.0.0.1" allowed="true" /> 
        <add ipaddress="192.168.78.0" subnetmask="255.255.255.0" allowed="true" />
        <add ipaddress="193.167.89.0" subnetmask="255.255.255.0" allowed="true" />
      </ipsecurity>
</security>


现在,我要检查用户使用此列表输入的ipadddress.

有人可以提出一些想法吗?

在此先感谢您.


now I want to check ipadddress entered by user with this list.

can any one suggest some ideas?

Thanks in advance.

推荐答案

您已阅读以下内容:
Have you read this: http://www.stokia.com/support/misc/web-config-ip-address-restriction.aspx[^]?

This settings is handled by IIS, thus if the user ip is blocked, your code will never got notified.


1.将库导入为:
1. Import library as:
Import System.Configuration


2.将配置数据读取为:


2. Read config data as:

string configIP1 = ConfigurationManager.AppSettings["ip1"];


3.验证用户输入为:


3. Validate with user input as:

string user_input = txtUserInput.txt
if(user_input.Equals(configIP1))
{
//Valid ip entered
}
{
//Invalid ip entered
}



希望这就是您要寻找的...

希望对您有帮助.

〜Amol



I hope this is what you are looking for...

Hope this will help you.

~Amol


仅当像
那样配置IIS管理器角色服务时,IPSecurity标记才起作用
http://www.iis.net/configreference/system.webserver/security/ipsecurity/add#006 [^ ]

但是我们无法为Windows XP或任何客户端计算机配置此功能.

它只能在Windows Server2008和Vista中完成.

因此我们可以将IP地址列表添加为

The IPSecurity tag will be work only if IIS manager Role Service is configuered like

http://www.iis.net/configreference/system.webserver/security/ipsecurity/add#006[^]

But we can''t configure this for windows xp or any client machine.

It can be done only in windows server2008 and vista.

So we can add list of ip address as

<appSettings>
    <add key="RestrictIPAddress" value="192.168.78.0 to 192.168.78.50,193.167.89.0 to 193.167.89.50"/>
  </appSettings>




使用这个名称,我们可以检查IP地址.




with this name we can able to check ip address.


这篇关于在web.config文件中添加ipaddress列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆