简体   繁体   English

触发ASP.NET网站服务器端推送的方法有哪些

[英]What are the approaches to trigger ASP.NET Website server side push

We are implementing Signalr to provide real time updates to browser clients. 我们正在实施Signalr,以向浏览器客户端提供实时更新。 But we are curretnly stuck as we need to make http server itself (IIS+ASP) detect the changes from database and external services or from any other source without polling? 但是,由于我们需要使http服务器本身(IIS + ASP)检测数据库和外部服务或任何其他来源的更改而无需轮询,因此我们深陷其中。 I believe this should be a common problem with all real time websites (irrespective of what technology is used for server side push SignalR, Comet or WebSync). 我认为这应该是所有实时网站的常见问题(无论服务器端推送SignalR,Comet或WebSync使用什么技术)。 Please provide what are general approaches used in such situations? 请提供在这种情况下使用的一般方法是什么?

If you can, raise an event in whatever code is updating your database. 如果可以,请使用任何更新数据库的代码引发一个事件。 Use that event to trigger the message publication. 使用该事件触发消息发布。

Ready to update database -> Update database
                         -> Publish to WebSync

If you can't control the code updating your database, use the SqlDependency class. 如果您无法控制更新数据库的代码,请使用SqlDependency类。 It lets you define a SELECT statement and then notifies you whenever the results of that query change. 它使您可以定义SELECT语句,然后在查询结果更改时通知您。 Use the notification event to trigger the message publication. 使用通知事件来触发消息发布。

Update database -> SqlDependency -> Publish to WebSync

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM