Asyncronously receiving data in an ASP.NET MVC application
I'm looking for the best way to constantly check if data has been sent to our ASP.NET MVC application from a server. I would like to asynchronously check for data and update the view when data has been read.
I'm currently using a TcpClient
to make a connection, and making the connection in the inherited custom base controller. Currently though I have to refres开发者_Python百科h the page for the updating of the view to take place.
Would there be a proper AJAX solution? or do I need to move the connection to the ActionMethod
?
For complete solution use this free library : PokeIn
I would probably use jQuery to query some action at a specified interval and update the page accordingly.
I don't know what kind of data you're talking about, but let's look at a simple example. From you're question, it sounds to me like you're trying to do the following:
Suppose you are building Twitter and want to show the newest Tweets on the homepage. Well, you could have a script that just does a jQuery.GetJSON call to some URL (let's call it twitter.com/latest5tweets) that gets the latest 5 tweets. Then you would have a callback function that would take those tweets and paint them on the screen -- perhaps using some sort of nifty slide effect to remove the older ones from the screen and add the new ones.
Does that help?
精彩评论