Real-time data display

Source: Internet
Author: User

Real-time Data display--SIGNALR instance Demo

In recent times, there is the function of realizing a kanban, that is, when the user updates the information, that is, when the data of the database is inserted, updated, or deleted, the data of the screen on the wall does not need to be refreshed, and the user can see the updated data.

To implement this functionality, Insus.net uses the SIGNALR technology. The following example, although not the actual data, but the implementation process is the same, and now share to everyone learn to learn ...


To install SIGNALR in your project:

, install the green-to-hook components.

After the installation is complete, you see a Readme.txt file:

This you should know what it is saying. Look, in the App_start directory, create a class with the class named Startup:

Next, we need to add the following highlighted 2 lines of code in the Application_Start and Application_End methods of Global.asax.cs:

Of course your Web. config file also has to add a real MS SQL Server connection statement.

TableB Model:

Now, in the item directory, create a signalr directory where we can add the Hub class:

The method names used by all clients are used in hump notation, and lowercase starts.

Now, we need to implement the database to get the data, when the data of the database changes, the client can also display in real time:



The blue arrow in the Hub method, that is, the Show method (#17行代码) in the previous diagram. In addition, for the SqlDependency class, you can check the MSDN website.

In the controller for the MVC project, we create 2 action actions:

To create a view, refer to the following steps:



The above # # and # # are the same. After ASP. 4.0, you can use ~/SIGNALR/JS, but in the new version. NET is, the use of # # of the wording or line.

In addition, the sequence of reference JS is fastidious. Refer to jquery First, then refer to signalr, then quote # # or # #.

The JS code for the above tag, see below:


The style code labeled # # Above:

Source Code

The following is a live demo, Insus.net has a few browser edge,ie,firefox,chrome, and in the database to add records, modify data and delete data, all clients can display in real time:


Categories: ASP., ASP, JQuery, JSON, SignalR

Real-time data display

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.