TypedRouting for ASP.NET Core MVC 2

Today I have released a new version of Strathweb.TypedRouting.AspNetCore. This new version is built as .NET Standard 2.0, and – obviously – finally supports ASP.NET Core MVC 2.

Here is a short summary and some links to help you get started.

Background

As I’ve already blogged here and here, so if you are interested in a more detailed explanation, I recommend checking out these articles. However, in short, Strathweb.TypedRouting.AspNetCore allows you to configure routes in your ASP.NET Core MVC applications using centralized, strongly-typed manner. This is in stark contrast to the two built in approaches of the framework: routing via attributes, or centralized routing without strong typing.

TypedRouting existed for ASP.NET Web API and was then migrated to ASP.NET Core MVC.

TypedRouting in ASP.NET Core MVC 2

Fundamentally, the ASP.NET Core MVC 2 version works the same way as the previous one, however, it contains a simplified and cleaner configuration/surface API. It is now only available on IMvcBuilder/IMvcCoreBuilder extension, and is decoupled from MvcOptions.

In your Startup class, after adding MVC, simply call AddTypedRouting(). The routes are configured using an options delegate. An example is shown below:

In addition to that, several painful bugs have been fixed – the main one is that the library now supports integration testing using the TestHost infrastructure, as it no longer persists static state.

I encourage you to give the library a try, it can be installed from Nuget, using the Nuget client:

or via the .NET Core CLI:

In case you have any issues, or would like to help out, please visit the Github repo.

Share the post!