Using TopShelf for windows service

Windows service runs continuously in the background and more often used as a back-end job. Its a pain if you want to debug it,even though you use logger to capture all events.we either attach the service as a process and debug it. But TopShelf lets you eliminate all of these and allows you to debug like console  application.

Topshelf has a start and stop method just like a service and also an separate command to install windows service with ease.

DocLink :


Object Comparisons — Difference between Equals method and ==

When we compare two objects with same content,there is a difference between “Equals and  == “.

Equals :

The Equals method does the content based comparison between two objects.

== :

“==” compares only object references.

Scenarios :

Sample s = new Sample () { a = "Hey" };
Sample s1 = s;
Sample s4 = new Sample () { a = "Hey" };

 Console.WriteLine(s1==s);  // True --Compares the instances 

Console.WriteLine(s==s4); // False ---Eventhough content is same,still == looks only for reference.

Console.WriteLine(s.Equals(s4)); // True --- Compares the value in field "a"  in both object and returns true.

String is an exceptional case and its immutable. It behaves with == as Equals.







WebHook in .NET

What is WebHook ?

A webhook is a provider that helps you to get data from external system  as and whenit flows into the system.These are real time data that is exposed over HTTP as and when data flows into system.

Components in WebHook :

Receiver : This type of webhook pulls the data  from external system to your server.

Sender  : This type of webhook is responsible for exposing your data to external system.

WebHook with .NET :

.NET does support web hook and there are various type of web hook that is customized  according to business need.

Types of WebHook Libraries provided by .NET :

  1. GitHubWebHook.
  2. SlackWebHook.
  3. GenericWebHook (This is the one which you use at custom level,the webhook is not tied to any providers like github,stripe instead you can define/customize  to your needs)

References :

SetInterval and ClearInterval -Javascript

I had been developing a real time chat system at my work  and the chat system takes some time to load(makes an ajax call to the backend that fetches users details,chat message,chat room id ,chat user role id etc..).and also there are multiple chat rooms based on user roles. The challenge was to wait for all of data to load  and then enable the chat system.

Solution :

The solution  is to wait for x interval of time and then make a call x time to check if the data we require is loaded.


var intialloading=false;
var someinterval =setInterval(function(){



//clear the interval.



},2000) // call function every 2 secs

function waitoperation()


//some call







Layouts in MVC

Layouts are used when there is a need to maintain a consistent look across multiple views.(Example : Header and footer across views).They are similar to master pages in ASP.NET.

Important Methods in Layouts :


1.Renders View and all of its components in layout page.

2.There can be only one RenderBody in a layout page.



1.Renders the specified page in layout.It takes an argument that specifies the location of page.


2.There can be multiple RenderPage method in layout.


Renders the content of page in specified region  in layout.


1.Requires name of the section.If not specified exception will be thrown.

2.IsRequired attribute in section method has to be set to false,if section is not mandatory for every view,else an exception will be thrown.