【发布时间】:2015-01-21 16:49:52
【问题描述】:
有没有类似的东西:
[Allow IP 123.123.12]
public ActionResult MyMethod(string xml)
{
//Only allow posts from the above IP
}
【问题讨论】:
-
您应该在 IIS 中执行此操作,而不是 MVC。为一个在进入管道之前就可能被拒绝的请求支付 CPU 处理成本是没有意义的
-
同意@PanagiotisKanavos,除非您不拥有部署环境(也许在 .config 中有一种方法)。从 Authentication 属性继承(我不记得确切的名称)并应用您自己的规则很容易。
-
Panagiotis Kanavos - IIS 听起来更好,你能提供在哪里处理吗?
标签: c# asp.net asp.net-mvc-4