Skip to content
A lightweight web framework built around the Mediator pattern. Use as an alternative to ASP.NET for sites that only require simple web services.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

PingPongr Build status NuGet

A lightweight web service framework.

The framework itself is extremely lean, with minimal dependencies and most of the configuration burden pushed down to the IoC container and other middlwares. This allows for more flexibility when infrastructure concerns change without having to change your own business logic.

The core router concept was originally based off the infinitely useful MediatR by Jimmy Bogard. See his blog post "Tackling cross-cutting concerns with a mediator pipeline" for more information on using this pattern.

Getting Started

To get started with the common defaults, install these nuget packages. This includes the "core" PingPongr abstractions, extensions for working with AspNetCore's hosting, and a default JSON serializer.

Install-Package PingPongr
Install-Package PingPongr.Extensions.AspNetCore
Install-Package PingPongr.Serialization.JsonNet


The basic API consists of the request, the response, and the core handler that processes the request.

Here's a fully functional and self hosted example.

namespace Examples.Simple
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.DependencyInjection;
    using PingPongr;
    using PingPongr.Serialization.JsonNet;
    using System.Threading;
    using System.Threading.Tasks;

    // A request is unqiue per route.
    // It defines what response type is expected.
    public class Ping : IRouteRequest<Pong>
        public string Message { get; set; }

    // Response types can be shared between requests.
    public class Pong
        public string Reply { get; set; }

    // A handler processes a request and returns a response.
    public class PingHandler : IRouteRequestHandler<Ping, Pong>
        public Task<Pong> Handle(Ping request, CancellationToken cancellationToken)
            // Do something cool here. (This example is not cool.  Be cooler.  Be amazing.)
            return Task.FromResult(new Pong() { Reply = "re: " + request.Message });

    public class Startup
        public void ConfigureServices(IServiceCollection services)
            // add the route handlers to the service registrations.

            // Using the PingPongr.JsonNet media handler.
            services.AddSingleton<IMediaTypeHandler, JsonNetMediaHandler>();

        public void Configure(IApplicationBuilder app)
            // Add PingPongr to the app pipeline.

            // By default, the endpoint will be available at:  Examples/Simple/Ping

    public class Program
        public static void Main(string[] args)

        public static IWebHost BuildWebHost(string[] args) => new WebHostBuilder()

In this default example, sending { Message: 'Hello' } to http//:localhost:5000/Examples/Simple/Ping, would result in the response { Reply: 're: Hello'}.

Check out the Examples.Complex project to see a more fleshed out sample with custom routes, logging decorators and service injection.

You can’t perform that action at this time.