jQuery 如何在 ASP.NET MVC 中执行长轮询 AJAX 请求?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1342216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to do long-polling AJAX requests in ASP.NET MVC?
提问by Andrew Arnott
Does anyone know how to code up long-polling AJAX requests (for server PUSH notifications) in ASP.NET MVC? Whenever I do it, it seems that only the last browser to open up a window gets the notifications. As if IIS/ASP.NET were canceling the last request because it was hung or something.
有谁知道如何在 ASP.NET MVC 中编写长轮询 AJAX 请求(用于服务器推送通知)?每当我这样做时,似乎只有最后一个打开窗口的浏览器才会收到通知。好像 IIS/ASP.NET 正在取消最后一个请求,因为它被挂起或其他原因。
回答by Jacob
I recently wrote a simple example of a Long Polling Chat Serverusing MVC 3 Async Controllers based on a great article by Clay Lenhart
我最近根据Clay Lenhart 的一篇精彩文章编写了一个使用 MVC 3 异步控制器的长轮询聊天服务器的简单示例
You can use the example on a AppHarbor deploymentI set up based on the source from the BitBucket project.
您可以在我根据 BitBucket 项目的源设置的 AppHarbor 部署中使用该示例。
Also, more information available from my blog post explaining the project.
此外,我的博客文章中解释了该项目的更多信息。