IIS / ASP.NET MVC:在特定的文件夹动态IP地址限制 [英] IIS/ASP.NET MVC: Dynamic IP Address Restrictions on specific folder
问题描述
由于它是如何工作的,这将是微不足道使用的WebForms做的,但我看不到一个合乎逻辑的方式使用MVC做到这一点。
我有我的应用程序(公共API),我想它应用特定的动态IP限制的一部分(所以我需要有一个仅适用于应用程序的某些部分Web.config文件)。
在的WebForms,我只需创建一个文件夹,并把Web.config文件中与它相关的限制。
有没有办法用MVC做到这一点?
Because of how it works, this would be trivial to do using WebForms, but I can't see a logical way to do it using MVC. I've a part of my application (the public API) that I'd like to apply specific Dynamic IP Restrictions on it (so I need to have a Web.config file that applies only to some part of the app). In WebForms, I'd simply create a folder and put a Web.config file in it with the associated restrictions. Is there a way to do this with MVC?
推荐答案
元素的位置仍然可以使用MVC应用配置(如IP限制)到你的MVC应用程序的某些部分:
Location elements can still be used in MVC to apply configuration (like IP restrictions) to certain parts of your MVC app:
<location path="secret/api">
<system.webServer>
<security>
<ipSecurity allowUnlisted="false">
<clear/>
<add ipAddress="127.0.0.1"/>
</ipSecurity>
</security>
</system.webServer>
</location>
这篇关于IIS / ASP.NET MVC:在特定的文件夹动态IP地址限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!