title: Asp.net Custom Web hook
body: <p>I am trying to learn webhooks, my requirement needs to have a publisher which can publish some data and all its subscriber will receive webhook notification.
  Here my requirement i needs to have both publisher and receiver in local host.</p>
  
  <p>I am trying out using the following post.
  <a href="http://blogs.msdn.com/b/webdev/archive/2015/09/15/sending-webhooks-with-asp-net-webhooks-preview.aspx" rel="nofollow">http://blogs.msdn.com/b/webdev/archive/2015/09/15/sending-webhooks-with-asp-net-webhooks-preview.aspx</a></p>
  
  <p>How ever when i call the subscribe method it fails. Please advice, whether i am doing any thing wrong.</p>
  
  <pre><code>function subscribe() {
  $.ajax({
      type: "POST",
      url: "/api/webhooks/registrations",
      data: JSON.stringify({
          WebHookUri: "http://localhost:59927/api/webhooks/incoming/custom",
          Secret: "12345678901234567890123456789012",
          Description: "My first WebHook!"
      }),
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(data, status) { alert(status); },
      failure: function(errMsg) { alert(errMsg); }
  });
  return false;
  </code></pre>
  
  <p>}</p>
  
  <p>This is the error message when i call subscribe method.</p>
  
  <p>"Message":"WebHook verification failed. Please ensure that the WebHook URI is valid and that the endpoint
   is accessible. Error encountered: NotFound","ExceptionMessage":"WebHook verification failed. Please
   ensure that the WebHook URI is valid and that the endpoint is accessible. Error encountered: NotFound"
  ,"ExceptionType":"System.InvalidOperationException"</p>
  
  <p>and this is my WebApiConfig.cs file</p>
  
  <pre><code>public static class WebApiConfig
  {
      public static void Register(HttpConfiguration config)
      {
          // Web API configuration and services
  
          // Web API routes
          config.MapHttpAttributeRoutes();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
  
          // Load Web API controllers 
          config.InitializeCustomWebHooks();
          config.InitializeCustomWebHooksApis();
          config.InitializeReceiveCustomWebHooks();
      }
  }
  </code></pre>
  
  <p>and Global.asax file</p>
  
  <pre><code>protected void Application_Start()
  {
          AreaRegistration.RegisterAllAreas();
          GlobalConfiguration.Configure(WebApiConfig.Register);            
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);
  }
  </code></pre>