How to Monitor Tasks with ASP.NET, SignalR and Bootstrap
How to Monitor Server Tasks with ASP.NET, SignalR and Bootstrap?
DotNet

How to Monitor Server Tasks with ASP.NET, SignalR and Bootstrap?

We all know that browsers are designed to get information from the server. Developers are able to push data to browsers from servers. The basic thing is to display the progress of a long running task within a web page in a browser.

This becomes very easy with ASP.NET, SignalR and Bootstrap. Here, in this blog post we will explain it how:

ASP.NET, SignalR and Bootstrap

Monitoring Server tasks with ASP.net:

Some of the web developers found an easy and effective way to display the progress of a server based process within a web page. They had done lot of struggle to develop one which can be easily updated with server side notifications.

This entire process consists of three stages:

  • A user clicks the button to initiate a lengthy task on the server.
  • The main user interface remains intact and a new DIV section is brought out into open and it displays the progress in the task.
  • As the task is about to finish on the server, various updates are reported and then these are automatically displayed in the IFRAME or DIV.

The main problem here is there’s no straight forward way for web clients to get updates from the server. The entire web works in the same way. Server requests get quick response but there’s no other way for a server to send autonomous messages which can be pushed to one or more clients.

Before ASP.net came into existence; all problems were solved by developers with the help of polling. Later with the arrival of this platform, a powerful framework came into existence which took traditional polling approach to next level.

It offers an easy way for every server to client push communication. This has been around for few years from now. The architecture and various steps to install ASP.net Signal R solution are discussed in various articles.

So, let’s take a look how this technology provides live updates on repeated connections and this will reveal how this can be used to implement progress bars as well as Bootstrap based bars in common:

Web Sockets and Server Sent Events:

ASP.net prefers to use Web sockets only when these are allowed by browsers and web servers. Web sockets need IIS 8.0 and Windows Server 2012. These also work in IIS 8.0 Express but not in Windows 7.

Any solution that is based on ASP.Net Signal R works as expected irrespective of the version of any of the web servers or operating system. This can be done by using HTTP for long when nothing better is available.

This new HTTP 1.0 protocol develops a new connection which is set up between the browser and web server for every request. When the response is sent, the connection is closed by the server. Later, the HTTP 1.1 protocol suggests that browsers must reuse the same connection to download multiple resources.

This saves the cost of repetitive TCP connections set up. There one has worthwhile improvement as it maintains the rule that one response is sent as per the request. Long polling can be used over HTTP 1.1 to have results from servers and clients working together.

As soon as the new request arrives, the server can send a quick response and then end the connection. When the response is not sent then headers are just sent back and then it waits for the complete response to be available.

Further, the connection is closed and then the browser repeats the request and then it is continued till the full response is obtained. The Web Socket protocol implements complete duplex communication over TCP.

However, on the same time frameworks can be developed to adapt it in order to support full duplex HTTP channel between a configured pair of browser and web server. This task is covered into several steps and every step marks the amount of work done.

The programming API is made of three methods: Notify Start, Notify Progress and Notify End. All these methods are defined in ASP.NET SignalIR hub class.

Wind Up:

The perfect combination of ASP.NET signal R and bootstrap has transformed the dream of web developers into reality. It is now possible to begin with potential lengthy task from the client and then stay informed about the progress as soon as it takes place on the server.

This needs lots of knowledge about intricacies of ASP. NET Signal R however it has been easier today. So, next time you wish to keep an eye on your server tasks then this blog will be a perfect guide for you.

Keep in touch with Softqube Technologies, a well known ASP.net application development in India.

Nitin Suvagiya

Nitin Suvagiya

He is working with Softqube Technologies as Director, since 2009. He has over 15+ years of experience in Microsoft Technologies, working as a CEO and also providing consultation in DevOps as he is DevOps certified. He has good expertise in UX/UI designing in any application.