Phema.Routing.Extensions.Caching 1.0.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Phema.Routing.Extensions.Caching --version 1.0.1                
NuGet\Install-Package Phema.Routing.Extensions.Caching -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Phema.Routing.Extensions.Caching" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Phema.Routing.Extensions.Caching --version 1.0.1                
#r "nuget: Phema.Routing.Extensions.Caching, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Phema.Routing.Extensions.Caching as a Cake Addin
#addin nuget:?package=Phema.Routing.Extensions.Caching&version=1.0.1

// Install Phema.Routing.Extensions.Caching as a Cake Tool
#tool nuget:?package=Phema.Routing.Extensions.Caching&version=1.0.1                

Phema.Routing

C# typed routing library for asp.net core

  • Core library
  • Extensions
  • Tests

Simple usage

// Startup
services.AddMvcCore()
  .AddRouting(routing => {});
  • You have two ways to add routing: using IMvcBuilder or IMvcCoreBuilder extensions - AddRouting
  • In AddRouting pass callback with IRoutingConfiguration to register route parts

Adding controller

// Startup
services.AddMvcCore()
  .AddRouting(routing =>
    // Add controller
    routing.AddController<TestController>("controller-route-part", controller => {});
  • To add controller you need to specify TController and route part
  • You can remove route part: AddController<TestController>(controller => {}).
  • It will be an empty string (so just / route)

Adding routes

// Startup
services.AddMvcCore()
  .AddRouting(routing => 
    routing.AddController<TestController>("controller-route-part", 
      // Add route
      controller => controller.AddRoute("action-route-part", c => c.TestMethod()));
  • To add action route you need to specify an action route (goes after controller route controller/action) and expression for method
  • By default route adds without any http method constraint (so you can call it with get, post, etc.)

Adding constraints

// Startup
services.AddMvcCore()
  .AddRouting(routing => 
    routing.AddController<TestController>("controller-route-part", 
      controller => 
        controller.AddRoute("action-route-part", c => c.TestMethod())
          // Add constraint
          .HttpGet());
  • You can add constraints to both: controller and route using IRouteBuilder returned by AddController or AddRoute
  • You can add them by using AddFilter/AddConstraint method with IServiceProvider parameter or extension without it
  • You can add named routes by using WithNamed method
  • To use predefined constraints and filters you need a Phema.Routing.Extensions package
  • For caching you can use Phema.Routing.Extensions.Caching package
  • To create custom filters and constraints you need IFilterMetadata or IActionConstraintMetadata in Microsoft.AspNetCore.Mvc.Abstractions package or inherit from derivatives
  • You can add HttpGet, Cached, etc. to controller's IRouteBuilder it means that any action inside will be HttpGet, Cached, etc.

Adding parameters

services.AddMvcCore()
  .AddRouting(routing => 
    routing.AddController<TestController>("controller-route-part", 
      controller => 
        controller.AddRoute("action-route-part", 
            // Add parameter source
            c => c.TestMethodWithStringParameter(From.Query<string>()))
          .HttpGet());
  • You can specify from wich source mvc will bind your model
  • To specify parameters you have to use From static class
  • To inject arguments from DI use From.Services method
  • From.* is matches [From*] attributes, so no more attributed parameters polluting your controller actions
  • To use From.Body don't forget to add mvc formatters using AddMvcCore
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated