开发者

ASP.NET MVC: How-to inform Model/View about changes in the repository?

开发者 https://www.devze.com 2023-03-26 19:36 出处:网络
I am using the Asp.NET MVC Framework, using CometD as a client for receiving new data from time to time. I listen for this data and add it to my database in a repository. Now I asked myself - how can

I am using the Asp.NET MVC Framework, using CometD as a client for receiving new data from time to time. I listen for this data and add it to my database in a repository. Now I asked myself - how can I inform a particular view or model about the fact, that new data is available?

Thanks very much for your help!

开发者_运维问答

Chris


Views are stateless. That is, the data they use is the data as it was at the point in time the View was generated, and that's it.

Once a view is rendered, it is sent back the the browser as a regular html page. To recieve push notifications via ajax using something like CometD, you would need to code something in the client side code (or however CometD does it)

The controller that recieves new data and updates the repository would be responsible for pushing the new data out to listening clients. But it would not be the MVC view that does the receiving (because views are rendered server side), it would be JavaScript running in a client browser.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消