title: How to make a "webhook"?
body: <p>I need the "WinForm" application for correspondence in viber.<br>
   "Webhook" is planned to receive data (events) from viber, then the data will be used in the application "WinForm".  </p>
  
  <p>I did:  </p>
  
  <ol>
  <li>created the project "ASP.NET Web Application (.NET Framework)"; </li>
  <li>chose a template - "Empty" + "MVC" + "API";  </li>
  <li>added controller "Controller MVC 5 - empty". Controller name "HookController";  </li>
  <li>I run the application "Postman";  </li>
  <li>"Postman". I set the request "POST";  </li>
  <li>"Postman". I set the link <code>http://localhost:44836/Hook</code>;  </li>
  <li>"Postman". Click "SEND";  </li>
  <li>The result, see the picture "- = RESULT = -";</li>
  </ol>
  
  <p>If I understand the theory correctly, then after performing the <code>"Postman" action. I click "SEND"</code>, the <code>ViberProcess (HttpContext context)</code> method should be executed in the <code>HookController.cs</code> controller and the code should stop at the <code>breakpoint</code>.<br>
  This is not happening.</p>
  
  <p>Documentation <code>Viber REST API</code> - <a href="https://developers.viber.com/docs/api/rest-bot-api/" rel="nofollow noreferrer">link</a></p>
  
  <p><strong>Question.</strong><br>
  How to make a Webhook?</p>
  
  <p><strong>Code <code>HookController.cs</code></strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  
  using System.Web;
  using System.Web.Mvc;
  
  //
  using System.Runtime.Remoting.Contexts;
  
  namespace WebAppl1.Controllers
  {
      public class HookController : Controller
      {
          // GET: Hook
          //public ActionResult Index()
          //{
          //    return View();
          //}
  
           [HttpPost]
          // [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
          public void ViberProcess(HttpContext context)
          {
              try
              {
                  Stream s = context.Request.InputStream;
                  // Stream s = Context.Request.InputStream;
                  // or  Stream s  =  HttpContext.Current.Request.InputStream;
                  s.Position = 0;
                  StreamReader reader = new StreamReader(s);
                  string jsonText = reader.ReadToEnd();
  
                  // Other code that converts json text to classes
              }
              catch (Exception e)
              {
                  // .....
              }
          }
  
      }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/1iEbG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1iEbG.jpg" alt="enter image description here"></a></p>
  
  <p><code>7. "Postman". Click "SEND";</code>
  <a href="https://i.stack.imgur.com/bWuQb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bWuQb.png" alt="enter image description here"></a></p>
  
  <p><code>8. The result, see the picture "- = RESULT = -";</code>
  <a href="https://i.stack.imgur.com/T0V1b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T0V1b.png" alt="enter image description here"></a></p>
  
  <p><code>Server error in application '/'.
  Could not find this resource.
  Description: HTTP 404. The resource (or one of its dependencies) may have been deleted, received a different name, or may be temporarily unavailable. Review the following URL and verify that it is correct.
  Requested URL: / Hook
  Version Information: Microsoft .NET Framework Version 4.0.30319; ASP.NET version: 4.7.3062.0</code></p>
  
  <p><strong>Update_1</strong><br>
  <strong>I use the link <code>http://localhost:44836/api/Hook</code></strong><br>
  The code does not stop at <code>breakpoint</code>.<br>
  Result:<br>
  <code>{<br>
  "Message": "Could not find the HTTP resource corresponding to the request URI \" http://localhost:44836/api/Hook\ ".", 
  "MessageDetail": "Could not find the type corresponding to the controller \" Hook \ " . "
  }</code></p>
  
  <p><strong>I use the link <code>http://localhost:44836/Hook/ViberProcess</code></strong><br>
  The code does not stop at <code>breakpoint</code>.<br>
  Result<br>
  <code>Server error in application '/'.
  For this object, no parameterless constructors are defined.
  Description: An unhandled exception occurred during the execution of the current web request. 
  Examine the stack trace for more information about this error and the code snippet that caused it.
  Exception Details: System.MissingMethodException: No parameter-less constructors are defined for this object.
  Source Error:
  An unhandled exception occurred during the execution of the current web request. 
  Information on the origin and location of the exception can be obtained using the following exception stack trace.</code></p>
  
  <p><a href="https://i.stack.imgur.com/tIfuw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tIfuw.png" alt="enter image description here"></a></p>