Simple library to use the ngrok Agent API. Start and stop tunnels programmatically.
Before you start using ngrok in your NET project, you need to make sure that ngrok is running. If not, run ngrok using the console, a script, or a background service.
ngrok start --none;
In your NET project, create a new instance of NgrokAgentClient
as follows.
using Ngrok.AgentAPI
api = new NgrokAgentClient();
Example:
// List all tunnels and do something
var resource = api.ListTunnels();
if(resource.Tunnels != null){
foreach (var tunnel in list.Tunnels)
{
var tunnelName = tunnel.Name;
// ...
}
}
Example:
// Start a new HTTP tunnel on port 5000 using http and https schemes
var configuration = new HttpTunnelConfiguration("MyLocalWebsite", "https://localhost:5000")
{
Schemes = new string[] { "http", "https" },
HostHeader = "localhost:5000"
};
var myTunnel = api.StartTunnel(configuration);
To see the list with all the methods, see the official webpage of the ngrok agent API documentation.