0

I want to display progress on my screen/page/view just as happens in console. So when i click install button, my "textarea" control should start displaying progress like

connecting to database connection successful running script a.sql running script b.sql operation complete connection closed

  1. Is textarea the correct control for this purpose?
  2. it Seems like there will be too many trips from server to the client just to write the progress on screen how can i minimize it?
0

2 Answers 2

2

To be able to do this easily, you can use SignalR which simplify all the hassle of which underlying technology to be used based on the version of the browser it will choose the best communication protocol (WebSocket, LongPolling..etc).

Behind SignalR, one of the underlying used technologies is websockets, it doesn't send anything except keep an open full duplex channels between server and client, in case any update in the server it will push this update to the client. most popular sites use websockets for keeping open channels between server and client.

SignalR uses actually websockets however it will downgrade to use long polling for example in case of old browsers that don't support websocket's connection upgrades.

You have the option to use the websockets directly in case you are assured your clients use new browsers.

One last thing Stackoverflow as a big and heavy loaded site uses websockets to update once there is a new answer or comment for example.

Sign up to request clarification or add additional context in comments.

3 Comments

for a single status page this is usually overkill. If you had a SPA which needed to constantly receive messages then I would recommend SignalR as well, but if you only have short-lived pages signalr introduces a lot of overhead.
the underlying technology is websockets, which doesn't send anything except keep an open full duplex channels between server and client, in case any update in the server it will push this update to the client. most popular sites use websockets for keeping open channels between server and client.
SignalR uses actually websockets however it will downgrade to use long polling for old browsers that don't support webscoket connection upgrades. stackoverflow as a big and heavy loaded site uses websockets to update there is a new answer or comment.
1

The general approach for this is just sending an ajax request every second or so and asking for an update from the server.

<div>
    <pre id="status">
    </pre>
</div>

setInterval(function () {
    $.ajax("/getUpdate?someParam=1234").then(function (result) {
        // result is whatever JSON object you send from the server
        $("#status").innerText = result.someProp;
    });
}, 1000);

It might look something like the above. Note that it's doing a request every second and storing the message from the server in the pre element.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.