win2kp.HttpListenerImpl
1.0.0
See the version list below for details.
dotnet add package win2kp.HttpListenerImpl --version 1.0.0
NuGet\Install-Package win2kp.HttpListenerImpl -Version 1.0.0
<PackageReference Include="win2kp.HttpListenerImpl" Version="1.0.0" />
paket add win2kp.HttpListenerImpl --version 1.0.0
#r "nuget: win2kp.HttpListenerImpl, 1.0.0"
// Install win2kp.HttpListenerImpl as a Cake Addin #addin nuget:?package=win2kp.HttpListenerImpl&version=1.0.0 // Install win2kp.HttpListenerImpl as a Cake Tool #tool nuget:?package=win2kp.HttpListenerImpl&version=1.0.0
<code> using System; using System.Net; using HttpAppController;
namespace ConsoleApp1 { class Program { private static string _appId = Guid.NewGuid().ToString(); static void Main(string[] args) { HttpAppController.HttpAppController controller = new HttpAppController.HttpAppController ( new System.Collections.Generic.Dictionary<string, string>(), // macros (%key) will be replaced with value in static html/text file 8080, // port to listen "/api", // prefix _appId, // appid for SSL enabled site "cert.pfx", // certificate used with SSL "password_to_export_cert", // password to export pfx cert true, // allow client to access static file in program folder (like html, txt, etc.) "." // Realm to used with authentication );
controller.AuthenLocal = true; // Authenticate user from localhost?
controller.NeedAuthentication = true; // Enable digest authentication on the site;
controller.SessionTimeout = 30000; // timeout for user session (ms)
controller.Request += Controller_Request;
controller.ClientAuthentication += Controller_ClientAuthentication;
controller.Start();
}
private static void Controller_ClientAuthentication(string username, ref string password, ref bool userExists)
{
userExists = true; //tell the username is valid
password = "password"; // tell the password for the username
}
private static void Controller_Request(Guid guid, HttpListenerRequest request, string cmd, System.Collections.Generic.Dictionary<string, string> param, dynamic json, ref string response)
{
// cmd: will be the "Command" part in url http://xxxxxx:8080/prefix/Command
// param: the querystrings within the request
// json: JSON entity posted from client (if applicable)
// response: the content will be sent to client
if (cmd == "Hello")
{
response = "Hello, " + param["name"];
// response = "Hello, " + json.name;
}
}
}
} </code>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Newtonsoft.Json (>= 8.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
First upload