I am working with .NET for my project. I would like to know how to set a refresh of a page for the the people seeing this page when an event occurs. For example, an auction: people have their page refreshed automatically with the new amount when someone bids.

I want to display the quantity available of an item in real time. So all the users know how many are left and it is updated as soon as one user purchases an item.

有帮助吗?

解决方案

Sounds like a candidate for SignalR.

其他提示

I think you are looking for a Timer. You could call a server side function frequently to check if a new event occured (someone bids) and then display an update.

Some examples here.

You cannot trigger a refresh from server side - you need to do it the other way around - frequently check if something has changed.

You can do that with AJAX and setTimeOut(). Set a timer to trigger an AJAX let's say every 1 minute, and in the AJAX method you can check if there are not read Auctions or so, in other words, your logic, and if the conditions are satisfied, you can get the AJAX's return to perform, for example, a window.navigate("auctionspage.html"); and redirects the user to a specific page. Be sure to check that the user did read the page so he won't be redirected again in the next setTimeOut() call.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top