How to convert node.js to C# code

mostafa ahmed 21 Reputation points

I have this code in node.js and I need to convert it to C# code This method I have to implement it in my project to be consume from other platform.

But it is coded in Node.js and I am using ASP.NET MVC and I do not have idea in node.js anymore'/webhook', (req, res) => {

    var response


    const message = `v0:${req.headers['x-zm-request-timestamp']}:${JSON.stringify(req.body)}`

    const signature = `lj5423j54235423`

    if (req.headers['x-zm-signature'] === signature) {

        if (req.body.event === 'endpoint.url_validation') {
            response = {
                message: {
                    plainToken: req.body.payload.plainToken,
                    encryptedToken: 'retwertwertewr5432fgds'
                status: 200



My major problem here how to recieve req & res arguments in method and get data from header & body I try this but not works:

public ActionResult Hooksd(HttpRequest req, RestResponse res)
Microsoft Technologies based on the .NET software framework.
3,605 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
3,405 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
936 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,611 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 61,026 Reputation points

    in MVC you don't pass the request and response objects as parameters, they are properties:

    public ActionResult Hooksd()
       var req = Request;
       var res = Response;
       var signature = "lj5423j54235423";
       // convert body to dynamic object
       req.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
       var json = new StreamReader(req.InputStream).ReadToEnd();
       dynamic body = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
       req.Headers["x-zm-request-timestamp"] == signature)
            return Json(new {
                message = new {
                    plainToken =  body.payload.plainToken,
                    encryptedToken = "retwertwertewr5432fgds"

    as C# is a typed language, you either have to define a class definition for the posted json, or use a dynamics json library

    0 comments No comments