Merge branch 'merge/release/2.2-to-master'

This commit is contained in:
Kiran Challa 2018-07-19 14:56:07 -07:00
commit 1e9640fcad
4 changed files with 630 additions and 468 deletions

View File

@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Routing
{
var matchProcessorReference = endpoint.MatchProcessorReferences[i];
var parameter = endpoint.ParsedTemplate.GetParameter(matchProcessorReference.ParameterName);
if (parameter.IsOptional && !routeValues.ContainsKey(parameter.Name))
if (parameter != null && parameter.IsOptional && !routeValues.ContainsKey(parameter.Name))
{
continue;
}

View File

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing.Constraints;
using Microsoft.AspNetCore.Routing.Internal;
using Microsoft.AspNetCore.Routing.TestObjects;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@ -1843,21 +1844,5 @@ namespace Microsoft.AspNetCore.Routing
return new DefaultInlineConstraintResolver(routeOptions.Object);
}
private class CapturingConstraint : IRouteConstraint
{
public IDictionary<string, object> Values { get; private set; }
public bool Match(
HttpContext httpContext,
IRouter route,
string routeKey,
RouteValueDictionary values,
RouteDirection routeDirection)
{
Values = new RouteValueDictionary(values);
return true;
}
}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Routing.TestObjects
{
internal class CapturingConstraint : IRouteConstraint
{
public IDictionary<string, object> Values { get; private set; }
public bool Match(
HttpContext httpContext,
IRouter route,
string routeKey,
RouteValueDictionary values,
RouteDirection routeDirection)
{
Values = new RouteValueDictionary(values);
return true;
}
}
}