Webhooks Support in ASP.NET
Webhooks is a popular pattern that has been available for a while now and has already been exposed by some popular service providers such as DropBox, GitHub, PayPal and MailChimp, amongst others. Webhooks are simple Pub/Sub models that allows a consumer to subscribe to events published by services. For example, you can subscribe to an event in DropBox whenever a new file is created or an existing file is updated. Similarly, in GitHub you can subscribe to the code commit information.
The .NET web development team recently announced the support for Webhooks in ASP.NET. You can now both send and receive Webhooks with ASP.NET MVC 5 and Web API 2. Although still in preview, it provides out-of-the-box support for DropBox, PayPal, Slack, WordPress, etc. The receiver model allows you to receive Webhooks from these providers as well as custom Webhooks that you may have created (like other ASP.NET MVC 5 web applications or Web API 2.0 services).
On the sender side, it provides support for storing and managing subscriptions. You can also use the sender and receiver parts in isolation. The way the Webhooks functionality works in ASP.NET is that the Webhooks server exposes the event subscription information. It then creates an HTTP POST to the matching subscriber URI based on the filters describing the event, along with the message payload.
For the receiver side, you must install the appropriate NuGet packages for receiving the Webhooks. For example, you must install the
Microsoft.AspNet.WebHooks.Receivers.GitHub package to receive Webhooks from GitHub. If you want to create a receiver from a custom ASP.NET site, then you must install the
A good use case for Webhooks is to subscribe to events happening in SalesForce. Although SalesForce doesn't directly expose Webhooks, the SOAP services inside can be configured for the Webhooks pattern to publish events. The article here describes the details of configuring SalesForce for Webhooks.