This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14970|Reply: 0

[ASP.NET] .Net MVC implements long polling

[Copy link]
Posted on 12/1/2017 11:25:03 AM | | |

What is long polling?

    Long polling is a method of "server pushing" technology, which can transmit changes on the server to the client in real time without the need for the client to frequently refresh and send requests.

How long polling works?

    The client sends an Ajax request to the server, and after the server receives the request, it keeps the connection and does not return a message, and does not return the response information until the relevant processing is completed.

Use cases for long polls?

    Long polling is often used in scenarios such as web timely communication, monitoring, and instant quotation systems that need to send changes from the server to the client in real time.

Pros and cons of long polling?

Pros: Requests to the server are not frequently sent when there are no messages.

Disadvantages: Servers are more resource-intensive to keep connected

Implementation:

Front Desk Code:

In the callback, we call the function again so that after each request is closed, the next request begins.



Background Code:

Our backend controller uses asynchronous and inherits the AsyncController base class








Previous:WebAPI customizes the return data format
Next:[Figure] Illustration of the evaluation of Yunfan flow ore flow treasure box
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com