DEV Community

Cover image for SimpleW
stratdev
stratdev

Posted on

SimpleW

Hey everyone! ๐Ÿ‘‹

After years of working with ASP.NET and other heavy frameworks, I wanted something simpler, faster, and more transparent for building custom web servers in .NET.

So I built SimpleW โ€” an open-source library that gives you full control over HTTP handling, without all the magic layers.

๐Ÿงฉ What it is

SimpleW is a lightweight web server library for .NET designed to:

  • Build HTTP servers in just a few lines of C#
  • Handle routes, static files, WebSockets, and middleware easily
  • Run on Linux/Windows (tested on Debian, NixOS, and Windows)
  • Stay dependency-free and minimal (no ASP.NET Core required)

โšก Why I made it

Most .NET web stacks are powerful but complex. I wanted a minimal, hackable server that could be dropped into any app, or used as a base for custom frameworks, game servers, or embedded tools โ€” while still delivering very good performances.

using System.Net;
using SimpleW;

namespace Sample {
    class Program {

        static void Main() {

            // listen to all IPs on port 2015
            var server = new SimpleWServer(IPAddress.Any, 2015);

            // find all Controllers classes and serve on the "/api" endpoint
            server.AddDynamicContent("/api");

            // start non blocking background server
            server.Start();

            Console.WriteLine("server started at http://localhost:2015/");

            // block console for debug
            Console.ReadKey();
        }
    }

    // inherit from Controller
    public class SomeController : Controller {

        // use the Route attribute to target a public method
        [Route("GET", "/test")]
        public object SomePublicMethod() {

            // the Request property contains all data (Url, Headers...) from the client Request
            var url = Request.Url;

            // the return will be serialized to json and sent as response to client
            return new {
                message = "Hello World !"
            };
        }

    }

}
Enter fullscreen mode Exit fullscreen mode

Thatโ€™s it โ€” youโ€™ve got a working HTTP server.

Iโ€™d really appreciate any feedback or ideas you might have ๐Ÿ™‚ !

๐Ÿ’ก Links

Top comments (0)