简体   繁体   中英

IIS/ASP.NET MVC: Dynamic IP Address Restrictions on specific folder

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM