ASP.NET - Efficiently delay code execution for single request?

一曲冷凌霜 提交于 2019-12-11 02:58:03

问题


I would like to delay code execution for a single request (based in IP address) efficiently without affecting the overall server performance (so Thread.Sleep is not an option?).

How can this be done?

(this is to annoy specific people for a certain amount of time, while still providing correct functionality when the time is over..)


回答1:


In my opinion, I wouldn't do such thing in your application layer, this is a Web server task rather than your own logic.

Instead of that, what about this IIS module?

  • http://www.iis.net/download/DynamicIPRestrictions



回答2:


you can do it serving content using pageMethods and delay the ajax call with javascript:

window.setTimeout(function () { PageMethods.RenderContent(); }, 100000);


来源:https://stackoverflow.com/questions/9314664/asp-net-efficiently-delay-code-execution-for-single-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!