Here are the steps to invoke Node.js from ASP.NET Core Website
public
void
ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddNodeServices();
}
public
class
HomeController : Controller
{
INodeServices
nodeServices;
public
HomeController(INodeServices nodeServices)
{
this.nodeServices =
nodeServices;
}
public
async Task<IActionResult>
About()
{
var
msg = await
nodeServices.InvokeAsync<string>("./hello.js",
1);
ViewData["Message"] = msg;
return View();
}
module.exports = function (callback)
{
var
message = 'Hello
world';
callback(null, message);
};
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.