win2kp.HttpListenerImpl 1.0.0

There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="win2kp.HttpListenerImpl" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add win2kp.HttpListenerImpl --version 1.0.0                
#r "nuget: win2kp.HttpListenerImpl, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 619 7/1/2019
1.0.0 527 6/27/2019

First upload