ElectronCGI is a library that enables making requests from a NodeJs application that are served by a .Net application.<p>It uses the standard in/out streams for communication.<p>To use it install the electron-cgi npm package on you node application and the ElectronCgi.DotNet nuget package on your .Net console app.<p>Here's an example:<p>In NodeJs/Electron:<p><pre><code> const { ConnectionBuilder } = require('electron-cgi');
const connection = new ConnectionBuilder()
.connectTo('dotnet', 'run', '--project', 'DotNetConsoleProjectWithElectronCgiDotNetNugetPackage')
.build();
connection.onDisconnect = () => {
console.log('Lost connection to the .Net process');
};
connection.send('greeting', 'John', theGreeting => {
console.log(theGreeting); // will print "Hello John!"
});
connection.close();
</code></pre>
And in the .Net Console Application:<p><pre><code> using ElectronCgi.DotNet;
//...
static void Main(string[] args)
{
var connection = new ConnectionBuilder()
.WithLogging()
.Build();
// expects a request named "greeting" with a string argument and returns a string
connection.On<string, string>("greeting", name =>
{
return $"Hello {name}!";
});
// wait for incoming requests
connection.Listen();
}
</code></pre>
[Blog post with extra information about ElectronCGI](<a href="https://www.blinkingcaret.com/2019/02/27/electron-cgi/" rel="nofollow">https://www.blinkingcaret.com/2019/02/27/electron-cgi/</a>)