【问题标题】:Adding Ip security for many locations为许多位置添加 IP 安全性
【发布时间】:2015-01-09 06:29:26
【问题描述】:

如何为多个位置添加多个规则

我有一个 MVC 应用程序我在 Web.Config 中添加了以下部分:

  <system.webServer>
     <security>
       <ipSecurity allowUnlisted="false">
          <clear /> 

       <add ipAddress="127.0.0.1" allowed="true" />

       <add ipAddress="41.111.32.153" allowed="true" />
       </ipSecurity>
    </security>
  <system.webServer>

现在我想添加另一个安全规则以允许某些 ips 仅访问主页,我尝试在基础项下添加此部分,例如:

<location path="Home">
  <system.webServer>
    <security>
      <ipSecurity allowUnlisted="false">
        <clear /> 
        <add ipAddress="44.244.6.162" allowed="true" />
        <add ipAddress="44.244.6.163" allowed="true" />
      </ipSecurity>
    </security>
  </system.webServer>
</location>

我也试过&lt;location path="Home" allowOverride="true"&gt;,但效果不佳!

你能告诉我我应该写什么来和我一起工作吗?

【问题讨论】:

标签: asp.net asp.net-mvc security web-config


【解决方案1】:

为什么不能使用授权过滤器?使用此方法,您可以在运行时添加 ip 配置,可能使用 SQL 表,并在每个操作中执行授权。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-11
    • 2016-11-12
    • 2017-02-28
    • 2019-03-24
    • 2015-10-08
    • 1970-01-01
    • 2015-05-14
    • 1970-01-01
    相关资源
    最近更新 更多