asp.net – 可以在Web.config中配置一个位置,只允许本地连接

我在ASP.Net应用程序中有一个页面(它的Mvc实际上并不重要),我只想允许从本地机器连接到此页面。我想在Web.config中做这样的事情:
<location path="resources"><system.web><authorization><allow ips="local"/></authorization></system.web></location>

我知道这可以通过简单的检查页面代码(或控制器)和its even possible just with IIS configuration,但我会喜欢一个Web.config配置,因为这将是我认为最优雅的解决方案。有人知道这是否可行?

谢谢

圭多

解决方法

您可以要求IIS通过Web.config中的IP地址限制对资源的访问:
<location path="resources">
  <system.webServer>
    <security>
      <ipSecurity allowUnlisted="false">
        <clear/>
        <add ipAddress="127.0.0.1"/>
      </ipSecurity>
    </security>
  </system.webServer>
</location>

More info

编辑:正如Mike在下面的评论中指出的那样,这需要安装IP和域限制模块。谢谢麦克

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....