Announcing the ASP.NET WebHooks Visual Studio Extension Preview
After a few days of work, I’m excited to introduce you to the ASP.NET WebHooks preview support we’ve put together for Visual Studio developers. This tool bootstraps your ASP.NET project with the NuGet packages and configuration code you’ll need so you can add custom processing for incoming WebHook requests from third parties like GitHub, Dropbox, and more. The 7-minute video embedded below demonstrates and end-to-end user experience offered by the WebHooks extension.
Over the past few weeks Henrik has been busy developing framework NuGets that enables WebHook support for ASP.NET, and he’s documented each step of the evolution of ASP.NET WebHooks on this blog. I’d highly encourage you take a look at some of these posts as context for how things work and what you can accomplish with the WebHooks preview:
- Introducing Microsoft ASP.NET WebHooks Preview
- Integrating with Instagram using ASP.NET WebHooks Preview
- Integrating with Slack using ASP.NET WebHooks Preview
- Sending WebHooks with ASP.NET WebHooks Preview
When I first saw the NuGets I realized we had a great opportunity to streamline things for developers who want to light up WebHook-reception support in their web apps. So let’s jump right in and explain how the WebHook tool can make life better.
How this WebHook extension simplifies your life
In the video above, you’ll see that the WebHooks wizard streamlines the process of selecting which WebHooks you want to support and for providing secrets that will be used to authenticate incoming requests. In most cases, the single variation in configuring individual incoming WebHooks is that each probably has it’s own secret. In my example scenario, I’ve created a custom SHA1 hash my app expects to be sent when GitHub calls me, and I need to use the Dropbox application secret. So the wizard first finds out which WebHooks I’d like to receive:
Then it captures the secrets for each of them individually. For the time being these are persisted into Web.config, but we see other opportunities – persisting them to config.json for vNext projects, persisting them directly into my Azure Web App settings. Crawl, walk, run…
Once the information is captured the NuGets are downloaded based on the list of providers I selected, and some code is added to my project that lights up the WebHooks I selected using the configuration extension methods available in each WebHook Receiver NuGet package.
The code for WebHookConfig.cs is shown below, after it was dropped into the App_Code folder of my Visual Studio project. It simply wires up each of the individual receivers according to the convention in place already.
For each of the selected receivers, a class is added to the project that inherits from the WebHookHandler class, the base class for all WebHook handler customizations you intend on doing. Each receiver is identified by name, with the name being used in the route wire-up, so each generated handler checks to see if it’s the one who should be handling the incoming requests. The Dropbox generated handler is below. The single change in the GitHub generated handler would be that it’s checking the receiver’s value against the string “GitHub,” and so on. In this way, you can light up multiple incoming WebHook requests, but only process according to the receiver’s context on your own.
The video demonstration walks through this in more detail, so I’d encourage spending a few minutes watching it to see the entire experience in action. None of the details are locked – this is a preview – so any feature ideas you have are on the table. Furthermore, the code for the ASP.NET WebHooks extension is open source and on GitHub, so feel free to fork the repository and improve it, submit issues and requests for ideas, and so on.
How can you install the extension
The extension is published into the Visual Studio Extensions Gallery, and can be downloaded in one of three ways. You can either go to the official Visual Studio Extensions Gallery download page here. With my buddy Mads Kristensen’s help, I have wired up a CI build of the extension so that each commit will rebuild and re-publish the extension into the VsixGallery.com extensions gallery. So if you’re amped on keeping up with the nightly builds of the extension as it evolves, you should install it from the VsixGallery page here. Alternatively, you can install the extension directly in Visual Studio using the “Extensions and Updates” dialog, as shown below. Simply search for “WebHooks” and it’ll pop up from either the official Visual Studio Extensions gallery or from the VsixGallery.com feed.
Summary and a feedback request
This tooling was written as a sidekick to Henrik’s WebHooks functionality and was inspired by it and my desire to make use of the new Connected Services SDK in Visual Studio to build something interesting and valuable for the community, so I’m interested in hearing some feedback in the comments, and would entertain some feature ideas in the GitHub repository storing the tooling code.
And again, this tool is a preview tool, so it may have some imperfections and bruised corners. If you see any, please submit an issue on the GitHub repository and well try to help. If you want to make some changes and get the code published, let’s discuss – overall the PR-approval process will be pretty quick and painless.