-4

Is there something like:

    [Allow IP 123.123.12]
    public ActionResult MyMethod(string xml)
    {

         //Only allow posts from the above IP
     }
user1668776
  • 3
  • 1
  • 4
  • 2
    possible duplicate of [Restrict access to a specific controller by IP address in ASP.NET MVC Beta](http://stackoverflow.com/questions/473687/restrict-access-to-a-specific-controller-by-ip-address-in-asp-net-mvc-beta) – Ajay Jan 21 '15 at 16:53
  • 1
    You should do that in IIS, not MVC. There's no point paying the CPU processing cost for a request that could be rejected before it even entered the pipeline – Panagiotis Kanavos Jan 21 '15 at 16:54
  • Agree @PanagiotisKanavos, unless you don't own the deployment environment (perhaps there is a way to do it in .config). It would be easy enough to inherit from the Authentication attribute (I can't remember the exact name) and apply your own rules. – Hal Jan 21 '15 at 16:56
  • Panagiotis Kanavos - IIS sounds even better, can you provide where this would be handled? – user1668776 Jan 22 '15 at 20:18

1 Answers1

0

Thank you Mr. Kanavos, yes this is much better handled with IIS and webconfig.

http://www.iis.net/configreference/system.webserver/security/ipsecurity

user1668776
  • 3
  • 1
  • 4