Live is streaming live. Watch now.

Route service in .NET

Route Services are often used in PCF to intercept requests to the applications and provide Authentication, Logging or other common functionality. You can read more on Route service Architecture

There are few examples in Java, Ruby, GO, and here is example implementation in .NET

One approach is to implement HttpHandler extending DelegatingHanlder and register it to process all requests:

public class ProxyHandler : DelegatingHandler
{
    protected  override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        return ProxyRequest(request, cancellationToken);
    }
}

And configure the handler to intercept requests:

// Intercepting backend calls
config.Routes.MapHttpRoute(
    name: "allpath",
    routeTemplate: "{*allpath}",
    defaults: null,
    constraints: null,
    handler: new ProxyHandler()
);

// Route Static files (js,css) requests too
RouteTable.Routes.RouteExistingFiles = true;		

Another possible approaches are to implement HttpModule or OWIN Middleware, or .NET Core Middleware

References

On This Page