/// <summary> /// Occurs when a no actions are matched by the route policy. /// </summary> /// <param name="context">The current <see cref="RouteContext">route context</see>.</param> /// <param name="selectionResult">The current <see cref="ActionSelectionResult">action selection result</see>.</param> protected virtual void OnUnmatched(RouteContext context, ActionSelectionResult selectionResult) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (selectionResult == null) { throw new ArgumentNullException(nameof(selectionResult)); } const RequestHandler?NotFound = default; var candidates = selectionResult.CandidateActions; var handler = NotFound; if (candidates.Count > 0) { var builder = new ClientErrorBuilder() { Options = Options, ApiVersionReporter = ApiVersionReporter, HttpContext = context.HttpContext, Candidates = candidates, Logger = Logger, }; handler = builder.Build(); } context.Handler = handler !; }
/// <summary> /// Occurs when a no actions are matched by the route policy. /// </summary> /// <param name="context">The current <see cref="RouteContext">route context</see>.</param> /// <param name="selectionResult">The current <see cref="ActionSelectionResult">action selection result</see>.</param> protected virtual void OnUnmatched(RouteContext context, ActionSelectionResult selectionResult) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (selectionResult == null) { throw new ArgumentNullException(nameof(selectionResult)); } #pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. const RequestHandler?NotFound = default; #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. var candidates = selectionResult.CandidateActions; var handler = NotFound; if (candidates.Count > 0) { var builder = new ClientErrorBuilder() { Options = Options, ApiVersionReporter = ApiVersionReporter, HttpContext = context.HttpContext, Candidates = candidates, Logger = Logger, }; handler = builder.Build(); } context.Handler = handler !; }