December 2019
Intermediate to advanced
510 pages
11h 33m
English
If default constraints don't cover all the business rules of your application, ASP.NET Core exposes all the necessary components to extend the behavior of route constraints so that you can define your own rules. It is possible to extend routing constraints by implementing the IRouteConstraint interface provided by Microsoft.AspNetCore.Routing, like so:
using System.Collections.Generic;using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Routing;namespace SampleAPI.CustomRouting{ public class CurrencyConstraint : IRouteConstraint { private static readonly IList<string> _currencies = new List<string> { "EUR", "USD", "GBP" }; public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary ...