问题
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