Reputation: 11816
i want to create a server-based chat application. i have been reading articles on how they do it but i am somehow not satisfied on how they do it.
i see them taking the last (let's say) 20 rows in their database which contains the new messages. but what if the newly inserted messages are 50, the other 30 messages will be surely not shown. in c# mvc3, in my controller action, how in LINQ (or if there's any other way) can i get the newly inserted rows... is there a smart way that when everytime an new row is inserted in the database, your c# code can get it automatically and pass it as a json object to your view?
i know that we should use ajax in posting new messages in the view, but as far as i know it in jquery.. there must be an event before the ajax function is called, like:
<script>
$('#btn').click(function(){ call ajax and post data which is a new message to the view});
</script>
how can you continuously call the ajax function to post new messages, without the page being refreshed?
Upvotes: 3
Views: 5278
Reputation: 12128
Have you tried SignalR?
There are plenty information online about building an MVC chat application with it.
Upvotes: 2