T
T
tmtm6532019-07-03 13:54:13
ASP.NET
tmtm653, 2019-07-03 13:54:13

How to send data from WebHook to WinForm?

I need a WinForm application that will be a client for Viber.
I have created a WebHook that accepts POST requests from the Viber server.
POST request contains JSON.
WebHook is created from ASP.NET Framework "Empty" + "MVC" template.
Question.
1. How can I make sure that if WebHook receives a POST request, then the received JSON is sent to "WinForm"?
2. If this solution is not acceptable, then how to properly organize the transfer of data from WebHook to WinForm within another solution?
Update_1
Purpose of the question: to first get acquainted with the principles of operation of `Viber Api`, ASP.
To do this, I suppose to host a
WinWorm (user interface) application on the local computer,
which will interact with the SQL server (or other database) and the WebServer (for interaction with the `Viber Api` server).
Everything is hosted on one computer and used by one user.
For the Internet, I will open the application with `Ngrok`.
The `Ngrok` service returns links like ` http://localhost:XXXXX` for links like ` https://6eb5a091.ngrok.io/` Update_1
. End. HookController.cs
Code

using System.Web.Mvc;
using System.IO;

namespace WebAppl.Controllers
{
    public class HookController : Controller
    {
        // *** Original code ***
        // GET: Hook
        //public ActionResult Index()
        //{
        //    return View();
        //}
                
        [HttpPost]
        public string Index()
        {
            using (var reader = new StreamReader(Request.InputStream))
                return reader.ReadToEnd();
        }

    }
}

5d1c892458a96684938101.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2019-07-03
@tmtm653

You can only have a WebHook for Viber on a dedicated IP, otherwise the request will fail.
There you will have a webserver that will process requests.
WinForm is a client application, so it must also connect to the server.
So rather passing data is
Viber ->[WebHook]->.net mvc server->[web sockets]->WinForm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question