I have an ASP.NET MVC project containing an AdminController class and giving me URls like these:
I want to configure the server/app so that URIs containing /Admin are only accessible from the 192.168.0.0/24 network (i.e. our LAN)
I'd like to restrict this controller to only be accessible from certain IP addresses.
Under WebForms, /admin/ was a physical folder that I could restrict in IIS… but with MVC, of course, there's no physical folder. Is this achievable using web.config or attributes, or do I need to intercept the HTTP request to achieve this?
Best Solution
I know this is an old question, but I needed to have this functionality today so I implemented it and thought about posting it here.
Using the IPList class from here (http://www.codeproject.com/KB/IP/ipnumbers.aspx)
The filter attribute FilterIPAttribute.cs:
Example usage:
1. Directly specifying the IPs in the code
2. Or, Loading the configuration from the Web.config