SWebServer 1.2.1
dotnet add package SWebServer --version 1.2.1
NuGet\Install-Package SWebServer -Version 1.2.1
<PackageReference Include="SWebServer" Version="1.2.1" />
paket add SWebServer --version 1.2.1
#r "nuget: SWebServer, 1.2.1"
// Install SWebServer as a Cake Addin #addin nuget:?package=SWebServer&version=1.2.1 // Install SWebServer as a Cake Tool #tool nuget:?package=SWebServer&version=1.2.1
SWebServer
SWebServer is the simplest web server you can find on the Internet. It is a C# library to setup a web server in the fastest possible way. You can easily develop your response pages writing callbacks function. An example is included.
Description
Server implementations share a common interface, ISWebServer. Actually there are 2 main implementation of ISWebServer:
- SWebServerTcp is built on top of Griffin.Framework. It doesn't require any privileges to run.
- SWebServerNetsh is build on top of Netsh (utility provided by Window). It requires admin privileges to be run.
Usage
To instantiate the web server based on TCP:
SWebServerTcp ws = new SWebServerTcp(SendResponse, 8081);
or Netsh-ed version:
SWebServerNetsh ws = new SWebServerNetsh(SendResponse, 8081);
where SendResponse is a function that manages the incoming requests, returning a string containg the body of the response. The simplest signature is:
string SendResponse(Stream request);
where the request contains the payload (body) of HTTP request. If request's body is empty, a NullStream is passed as input. Alternatively, a richer signature is:
string SendResponse(string method, string contentType, Stream request);
The response's code sent to the client is always 200, there is not possibility to change this code. Internal error derived from your application should be managed in the response's body.
To effectively start/stop the webserver:
ws.StartAndRun();
ws.Stop();
For more details check the example provided along with the source code.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Griffin.Framework (>= 2.1.1)
- Griffin.WebServer (>= 0.5.3)
- System.Reflection.Emit.Lightweight (>= 4.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
New method to add headers to HTTP response