Html Asp.Net MVC 和 HTML5 PUSH 通知
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12057003/
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
Asp.Net MVC and HTML5 PUSH notification
提问by J4N
I would like to have server side event in a full HTML5 application.
我想在一个完整的 HTML5 应用程序中有服务器端事件。
Server side I've an asp.net MVC3 web server, which gives HTML pages and JSON results.
服务器端 我有一个 asp.net MVC3 web 服务器,它提供 HTML 页面和 JSON 结果。
What is the best way to integrate some server event? Like a process which can send some text message to client?
集成某些服务器事件的最佳方法是什么?像一个可以向客户端发送一些文本消息的过程?
I've made some search and found something about a Asp.Net web api, but I don't know what it is and if I can use it with MVC.
我进行了一些搜索并找到了一些关于 Asp.Net web api 的信息,但我不知道它是什么以及我是否可以将它与 MVC 一起使用。
回答by DanielB
You should have a look at http://signalr.net/library. This blog postis also very informative.
您应该查看http://signalr.net/库。这篇博文也非常有用。
回答by Matt Klinker
SignalR looks very interesting, but maybe more than you really need. I've often wondered why people don't use Server-Sent Events more often, I haven't had the chance, but it looks like the simplest way of implementing.
SignalR 看起来很有趣,但可能比您真正需要的要多。我经常想知道为什么人们不更频繁地使用 Server-Sent Events,我没有机会,但它看起来是最简单的实现方式。
Here is an example in MVC if you want to review: http://blogs.microsoft.co.il/blogs/gilf/archive/2012/04/10/using-html5-server-sent-events-with-json-and-asp-net-mvc.aspx
如果您想查看以下 MVC 中的示例:http: //blogs.microsoft.co.il/blogs/gilf/archive/2012/04/10/using-html5-server-sent-events-with-json-和-asp-net-mvc.aspx