Answer the question
In order to leave comments, you need to log in
How to make a "Webhook"?
I need the application "WinForm" for correspondence in viber.
"Webhook" is planned to receive data (events) from viber, then the received data will be used in the "WinForm" application.
I did:
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)
{
// .....
}
}
}
}
Answer the question
In order to leave comments, you need to log in
You must have routing defined in your ASP.NET application.
As a rule, by default there is "Controller name"/['index']
where index is substituted as a default value.
app.UseMvc(routes => {
routes.MapRoute("default",
"{controller}/{action}",
new { controller = "Home", action = "Index" });
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question