简体   繁体   中英

How do I use IIS' IP Address and Domain Restrictions to deny access to my MVC controller method?

I have one method in my controller that I wish to limit access to using IIS' IP Address and Domain Restrictions feature.

This IIS feature works well to limit access to files and folders. Can it be used to limit access to my controller method? This method does not have an associated view, as it is simply receiving a postback.

My post url to my method is like: http://myserver.com/myControllerMethod

How can I restrict access by IP to this?

You will not be able to use IIS' IP Address and Domain Restrictions feature at action (method) level. It is site level feature. Alternatively you can write your own authorization filter which can read list of restricted domains and IPs from configuration file and check incoming request against that list.

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