Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Getting Started with Microsoft ASP.NET WebHook Preview

0.00/5 (No votes)
8 Sep 2015 1  
In this article, we will discuss about ASP.NET WebHook-Preview.

Editorial Notes

This article starts with Preview of Microsoft ASP.NET WebHook and needs update time-to-time. It would contain reference links for further discussion or clarifications. This is an ongoing article and needs lot of upcoming updates.

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:

Introduction

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

Through-out this article, we will discuss about WebHooks, implementation with very first preview release of 'Microsoft ASP.NET WebHooks Preview'.

Purpose

Currently, 'Microsoft ASP.NET WebHooks Preview' is not finalized for release and 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.

Pre requisite

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

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

What is WebHook?

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



We can also consider callback in C#, where we are performing few custom actions on results. Its not wrong if I say Program-A automatically trigered 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/ can not be a part of actual WebSite, Web Application, where Program-A belongs.

The term Web reminds us to HTTP. So, we can say that Webhooks are nothing but 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.

WebHooks:

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 day-to-day life, might be we missed these:

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

More Real time examples of WebHooks

Think a scenario of a factory, which uses a crude oild 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.

  • 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 this in real scenario?

What is the problem here?

In normal scenario, where the consumption of this crude oil is not so much and can esialy be maintained by manual interventions/activities. Unfortunately, in our case it is not so much simpler to take a byte of brea with Tea.

Here, we need skilled workers to maintain records and set the indicators accordingly so, related actiona 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 then?

There might be many solutions we can think over. But here are the possible solutions:

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

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

In my personal opinion, I should suggest to do something like this:

  • 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/substraction 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-scubscribe pattern/model - a messaging pattern. We can assume this as a message-queue paradigm too. We are not geeting in more depth for pub/sub model, please refer to below 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 lot of applications already provide, support WebHook, followings are fewer name:

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

Overview of ASP.NET WebHook Preview

There is nothing much change 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 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

Follow these simple step(s)

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

Points of Interest

Microsoft ASP.NET WebHook Preview provides us a facility to communicate outside without intervention of our internal implementation of ASP.NET application.

History

  • Initial version on September 09, 2015

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here