那岂不是每一个页面都要去判断ip是否合法????
我的目的是想让禁止的ip连访问都访问不了这个论坛。
是否有更底层一些的办法?
好像iis设置中设置拒绝ip某些ip访问这个网站,我是否可以动态的实现对iis这个功能的控制?

解决方案 »

  1.   

    1. use the services provided by IIS, run Internet Services Manager, right click on your virtual directory to open its Properties page, go to Directory Security tab, click on the second Edit button, enter the IP you want to grant/deny access, reboot your IISor2. in Application_BeginRequest handler in global.asax, check either Request.UserHostAddress or Request.ServerVariables["REMOTE_ADDR"], if it is an IP you want to deny, write out some messages with Response or call Response.Redirect and call CompleteRequest() method
      

  2.   

    you have to use IIS admin object mode, seeHow can I set 2000 IP address and domain name restrictions?
    http://iisfaq.com/default.aspx?View=A136&P=109
      

  3.   

    IIS 的虚拟站点的属性里面 ,目录安全性 -- ip及域名限制
      

  4.   

    我指的是在asp.net程序里动态实现!!!
    有没有那位能给一个中文文档,加一小段例子???谢谢!!!
      

  5.   

    老大,在.net中如何对iis进行操作。好象没有提供这方面的类。
    只能用vb调用以前的那些com对象。
      

  6.   

    哪位老兄能告诉我
    我的iis-目录安全性 -- ip及域名限制咋是灰色的,不能选呀
      

  7.   

    思归说的第二种,是个好方法(第一是IIS的IP限制,不够机动)在Global.asax中,使用“应用程序事件”,在请求中,对IP进行过滤。十多种事件,较常规的方法,是Application_OnStart(只一次),Application_OnBeginRequest(每请求),当然,可以与身份验证结合起来,如:Application_OnAuthorizeRequest。