Getting Started With Microsoft ASP.NET WebHook

Background

There was an announcement for 'Microsoft ASP.NET WebHooks Preview' on September 04, 2015, where Henrik F Nielsen announced the release of 'Microsoft ASP.NET WebHooks Preview' as a new member of ASP.NET family.

For more information regarding this announcement, please refer to the following link:

Introduction

In this article we will discuss about ASP.NET WebHook-Preview.

Throughout this article, we will discuss about WebHooks and implement the very first preview release of 'Microsoft ASP.NET WebHooks Preview'.

Purpose

Currently, 'Microsoft ASP.NET WebHooks Preview' has not finalized the release and it is in the stage where developer can try to use the magic of WebHooks in their code. In this article we will discuss more about this new member of ASP.NET family and try to understand the power of WebHooks using a simple program.

Prerequisite

There are no such major things required to start with WebHooks, we just need to know the following:

  • Basics of Services (Web APIs etc.).
  • Visual Studio 2013 or later.
  • Basic knowledge of ASP.NET.

What is WebHook

To understand the first think about a scenario, where we need to perform some action on the output/result of an existing action.



Figure 1: WebHook

We can also consider callback in C#, where we are performing few custom actions on the results. Its not wrong if I say Program-A automatically triggered with an input of output from ProgramA.

In simple words, we can say WebHooks are program/methods/functions/piece-of-code, which modified the actual behavior of a web page, application, resource etc.

The interesting thing is that these program/triggers can be/ cannot be a part of actual website, web application where Program-A belongs.

The term Web reminds us of HTTP, so we can say that WebHooks are nothing just HTTP callback, moreover these are user-defined HTTP callback. In year 2007, term WebHook came to announce, when Jeff Lindsay take it from Hook.

“WebHook is a lightweight HTTP pattern providing a simple pub/sub model for wiring together Web APIs and SaaS services. When an event happens in a service, a notification is sent in the form of an HTTP POST request to registered subscribers. The POST request contains information about the event which makes it possible for the receiver to act accordingly.”

Real time examples of WebHooks

We have lot of examples in our daytoday life, maybe we missed the following:

  • Checking-in/pushing a code into repository.
  • Trigging deployment build.
  • Posting comments on your favorite blogs.
  • Post Trackback.

More Real time examples of WebHooks

Think a scenario of a factory, which uses crude oil as a raw material. There is a huge consumption of this oil in the factory on daily basis. They have three mark to maintain the oil storage/stock level in the factory.


Figure 2: Example of Webhooks

  • Red for lowest stock and denotes stop usage.
  • Yellow for in stock and denotes can use.
  • Green for lower stock and denotes order to purchase more.

Think a scenario, where factory workers/store-keepers or field-supervisors are maintaining numerous records for the stock of this oil. You can think how much complex it would be in real scenario.

What is the problem here

In normal scenario, where the consumption of this crude oil is not much and can easily be maintained by manual interventions/activities. Unfortunately, in our case it is not simpler to take a bite of bread with tea.

Here, we need skilled workers to maintain records and set the indicators accordingly, so related action can be taken. Think, how much time, cost and manpower would be required in this scenario. Isn't it good to automate it?

What is the solution


There might be many solutions we can think over, but here are some of the possible solutions:

  • Automate this process.
  • Write a short program/app to maintain the difference in stock level.
  • Automate process, so related person get notified for action(s).

In all of  the above solutions, we need to trigger some action on the output of a particular action or talk. Isn't it related to WebHook?

In my personal opinion, I would suggest to do something like the following:

  • Write a program/app, which maintain the stock time-to-time (on/when action required).
  • And notify the Panel-section to alarm Red, Yellow or Green indicators.

With this solution as soon as there is any addition/subtraction in the quantity of crude-oil our program notify our Stock-Panel (which is nothing but similar to Traffic control light) and it trigers accordingly.

What is pub/sub model


This is nothing but a publish-subscribe pattern/model - a messaging pattern. We can assume this as a message-queue paradigm too. We are not getting in more depth for pub/sub model, please refer to the following link for further details.

Applications/Projects provide WebHook

Term WebHook is not new (already discussed above it is coined in 2007) in the world of Web. There are lots of applications already provided, that support WebHook. Here are some names:

  • Dropbox
  • GitHub
  • Trello
  • Zendesk
  • PayPal
  • SalesForce
  • Wordpress

Overview of ASP.NET WebHook Preview

There is nothing much changed in Microsoft ASP.NET WebHook Preview, it maintains the same publish-subscribe model/pattern as we discussed above.

In other words, we can say that ASP.NET WebHook does both send and receive Hook as/within ASP.NET application/program. It has the following two sides:

  • Sending
  • Receiving

Refer: http://blogs.msdn.com/b/webdev/archive/2015/09/04/introducing-microsoft-asp-net-webhooks-preview.aspx

How to start working with ASP.NET WebHook Preview

Here are the step(s)

  • Choose your package app which you want to use WebHooks viz. Github, Trello, DropBox etc.
  • Install from Preview Nuget eg. GitHub.
  • Alternatively, you can visit GitHub.

Notes for Editors

This article starts with preview of Microsoft ASP.NET WebHook and needs update time-to-time. It would contain reference links for further discussions or clarifications. This is an ongoing article and needs lot of upcoming updates (I am expecting to cover this within 100+ pages).

Up Next
    Ebook Download
    View all
    Learn
    View all