当前位置: 代码迷 >> Web Service >> webservice里怎么限制每IP每天只可以访问100次
  详细解决方案

webservice里怎么限制每IP每天只可以访问100次

热度:197   发布时间:2016-05-02 02:50:44.0
webservice里如何限制每IP每天只可以访问100次?
webservice里如何限制每IP每天只可以访问100次?要求24小时后自动解除限制
请教大家了 给点思想 谢谢

------解决方案--------------------
临时信息应该使用数据缓存。例如
C# code
var pos = context.Request.UserHostAddress.IndexOf(':');var ip = context.Request.UserHostAddress.Substring(0, pos);var cache = HttpRuntime.Cache;var today = DateTime.Now.ToString("y年M月d日");var key = ip + "于" + today + "是否禁用";var result = (bool)cache[key];if (result == null){    result = 查询当日访问次数(ip) >= 100;    cache.Insert(key, result);}
  相关解决方案