Skip to content

.net Express is a minimal and flexible .Net web application framework that provides a robust set of features for web and mobile applications.

License

Notifications You must be signed in to change notification settings

pynch-tv/dotNetExpress

Repository files navigation

example workflow

oie_NHyIgxVTsC9G

.net Express is a minimal and flexible .NET 9 web application framework that provides a robust set of features for web and mobile applications.

Key features

  • behaves like node.js Express
  • fully written in .NET 9.0 C#
  • fast
  • use WebSockets and SSE over the same port

Getting started

Hello world example

namespace dotNetExpress.examples;

internal partial class Examples
{
    internal static async Task HelloWorld()
    {
        var app = new Express();
        const int port = 8080;

        app.Get("/", async Task (req, res, next) =>
        {
            await res.Send("Hello World");
        });

        await app.Listen(port, () =>
        {
            Console.WriteLine($"Example app listening on port {port}");
        });
    }
}

Multirouter example

Demonstrates multiple routes, use of Params and Query

namespace dotNetExpress.examples;

internal partial class Examples
{
    internal static async Task MultiRouter()
    {
        var app = new Express();
        const int port = 8080;

        var apiv1 = new Router();
        var apiv2 = new Router();

        app.Use("/api/v1", apiv1);
        app.Use("/api/v2", apiv2);

        apiv1.Get("/", async Task (req, res, next) =>
        {
            var serverId = req.Params["serverId"];
            Console.WriteLine($"serverId {serverId}");

            var sLimit = req.Query["limit"];
            var sOffset = req.Query["offset"];
            Console.WriteLine($"Pagination {sOffset} {sLimit}");

            await res.Send("Hello World from api v1.");
        });

        apiv2.Get("/", async Task (req, res, next) =>
        {
            await res.Send("Hello World from api v2.");
        });


        app.Get("/", async Task (req, res, next) =>
        {
            await res.Send("Hello World from root route.");
        });

        await app.Listen(port, () =>
        {
            Console.WriteLine($"Example app listening on port {port}");
        });
    }
}

More examples in the Examples folder

Optional Dependencies

For Multipart POST commands

About

.net Express is a minimal and flexible .Net web application framework that provides a robust set of features for web and mobile applications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages