Best and Cheap ASP.NET SignalR Cloud Hosting

ASP.NET is Microsoft’s framework for building robust web applications. ASP.NET is Microsoft’s dynamic website technology, enabling developers to create data-driven websites using the .NET platform. ASP.NET SignalR is a library for ASP.NET developers that simplify the process of adding real-time functionality to applications. It is a innovative technology from Microsoft to convert the task of adding real time web functionalists to an ASP .NET or MVC4 applications easy. SignalR is for building applications that require live user interaction or real time data updates or for building connected applications that can send, receive and broadcast data in real time.

A Better Way of Using ASP.NET SignalR With Angular JS

In this post, we will give you a tutorial about ASP.NET SignalR, a better way of using ASP.NET SignalR with Angular JS. The way to go is using event methods defined on $rootscope object. This approach is based on publishing and subscribing events. As events can be published from anywhere and subscribed from anywhere, the source and destination will remain completely unaware of each other. Both of them have to depend on just one object, $rootScope. 
Official documentation on scope contains details on each method defined on $rootScope. We will be using the following methods for publishing and subscribing the events: 
  • $emit(name, args): Publishes an event with specified name with given arguments
  • $on(name, listener): Subscribes to an event with specified name. Listener is a function containing logic to be executed once the event has occurred
To manage SignalR’s client functionality, it is better to create a service, as services are singletons. There will be only one instance of the service in entire application. This behaviour of services makes it possible to have multiple SignalR client pages in the applications and they can be kept in sync without putting any extra amount of effort. 
Service carries the responsibility to initialize a connection to the hub and call the SignalR’s server methods. Once a response is received from the server, we will broadcast an event from the service with data received.
app.service('signalRSvc', function ($, $rootScope) {
var proxy = null;

var initialize = function () {
//Getting the connection object
connection = $.hubConnection();

//Creating proxy
this.proxy = connection.createHubProxy('helloWorldHub');

//Starting connection
connection.start();

//Publishing an event when server pushes a greeting message
this.proxy.on('acceptGreet', function (message) {
$rootScope.$emit("acceptGreet",message);
});
};

var sendRequest = function () {
//Invoking greetAll method defined in hub
this.proxy.invoke('greetAll');
};

return {
initialize: initialize,
sendRequest: sendRequest
};
});
To keep the things simple, I kept names of the server hub event and event rose using $emit the same. The names can be different. Let’s modify the controller to have a listener to the event raised by the service. Following is the implementation of the controller:
function SignalRAngularCtrl($scope, signalRSvc, $rootScope) {
$scope.text = "";

$scope.greetAll = function () {
signalRSvc.sendRequest();
}

updateGreetingMessage = function (text) {
$scope.text = text;
}

signalRSvc.initialize();

//Updating greeting message after receiving a message through the event

$scope.$parent.$on("acceptGreet", function (e,message) {
$scope.$apply(function () {
updateGreetingMessage(message)
});
});
}
Now open the modified page on multiple browsers and click the Greeting button randomly from all browsers. Messages printed on all browsers should be updated whenever the button is clicked. This behavior is same as it was earlier. We just adopted a better approach to make it work.

Best and Cheap ASP.NET SignalR Cloud Hosting

ASPHostPortal.com ASP.NET SignalR optimised hosting infrastructure features independent email, web, database, DNS and control panel servers and a lightning fast servers ensuring your site loads super quick! Reason why you should choose them to host your ASP.NET SignalR site:

ASPHostPortal.com is Microsoft No #1 Recommended Windows Hosting Partner
ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for the ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, .NET 4.5.2/ASP.NET 4.5.1, ASP.NET MVC 6.0/5.2, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

  • Easy to Use Tools – ASPHostPortal.com use World Class Plesk Control Panel that help you with single-click ASP.NET SignalR installation.
  • Best Programming Support – ASPHostPortal.com hosting servers come ready with the latest ASP version. You can get access directly to your MS SQL from their world class Plesk Control Panel.
  • Best Server Technology – The minimal specs of their servers includes Intel Xeon Dual Core Processor, RAID-10 protected hard disk space with minimum 8 GB RAM. You dont need to worry about the speed of your site.
  • Best and Friendly Support – Their customer support will help you 24 hours a day, 7 days a week and 365 days a year to assist you.
  • Uptime & Support Guarantees – They are so confident in their hosting services they will not only provide you with a 30 days money back guarantee, but also they give you a 99.9% uptime guarantee.
Rate this post