diff --git a/src/Microsoft.AspNet.Routing/RouteData.cs b/src/Microsoft.AspNet.Routing/RouteData.cs index e8992b79f0..7a93688717 100644 --- a/src/Microsoft.AspNet.Routing/RouteData.cs +++ b/src/Microsoft.AspNet.Routing/RouteData.cs @@ -6,8 +6,14 @@ using System.Collections.Generic; namespace Microsoft.AspNet.Routing { + /// + /// Information about the current routing path. + /// public class RouteData { + /// + /// Creates a new instance. + /// public RouteData() { DataTokens = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -15,6 +21,10 @@ namespace Microsoft.AspNet.Routing Values = new RouteValueDictionary(); } + /// + /// Creates a new instance with values copied from . + /// + /// The other instance to copy. public RouteData([NotNull] RouteData other) { DataTokens = new Dictionary(other.DataTokens, StringComparer.OrdinalIgnoreCase); @@ -22,10 +32,19 @@ namespace Microsoft.AspNet.Routing Values = new RouteValueDictionary(other.Values); } + /// + /// Gets the data tokens produced by routes on the current routing path. + /// + public IDictionary DataTokens { get; private set; } + + /// + /// Gets the list of instances on the current routing path. + /// public List Routers { get; private set; } + /// + /// Gets the set of values produced by routes on the current routing path. + /// public IDictionary Values { get; private set; } - - public IDictionary DataTokens { get; private set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs b/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs index 33e88554aa..dbfaa9c223 100644 --- a/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs +++ b/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs @@ -111,7 +111,7 @@ namespace Microsoft.AspNet.Routing.Template { _logger.WriteValues(CreateRouteAsyncValues( requestPath, - values, + context.RouteData.Values, matchedValues: false, matchedConstraints: false, handled: context.IsHandled)); @@ -121,9 +121,16 @@ namespace Microsoft.AspNet.Routing.Template return; } + var oldRouteData = context.RouteData; + + var newRouteData = new RouteData(oldRouteData); + MergeValues(newRouteData.DataTokens, _dataTokens); + newRouteData.Routers.Add(_target); + MergeValues(newRouteData.Values, values); + if (!RouteConstraintMatcher.Match( Constraints, - values, + newRouteData.Values, context.HttpContext, this, RouteDirection.IncomingRequest, @@ -133,7 +140,7 @@ namespace Microsoft.AspNet.Routing.Template { _logger.WriteValues(CreateRouteAsyncValues( requestPath, - values, + newRouteData.Values, matchedValues: true, matchedConstraints: false, handled: context.IsHandled)); @@ -142,13 +149,6 @@ namespace Microsoft.AspNet.Routing.Template return; } - var oldRouteData = context.RouteData; - - var newRouteData = new RouteData(oldRouteData); - MergeValues(newRouteData.DataTokens, _dataTokens); - newRouteData.Routers.Add(_target); - MergeValues(newRouteData.Values, values); - try { context.RouteData = newRouteData; @@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Routing.Template { _logger.WriteValues(CreateRouteAsyncValues( requestPath, - values, + newRouteData.Values, matchedValues: true, matchedConstraints: true, handled: context.IsHandled));