From a1fe088d3a910b75a3c48d8a9dd78830310f1134 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 9 Jun 2014 11:17:28 -0700 Subject: [PATCH] Removing RouteContext.RequestPath and calculating it from HttpContext as needed. --- samples/RoutingSample.Web/PrefixRoute.cs | 7 ++++--- src/Microsoft.AspNet.Routing/RouteContext.cs | 5 +---- src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/samples/RoutingSample.Web/PrefixRoute.cs b/samples/RoutingSample.Web/PrefixRoute.cs index d2b56b34ce..24ac32d461 100644 --- a/samples/RoutingSample.Web/PrefixRoute.cs +++ b/samples/RoutingSample.Web/PrefixRoute.cs @@ -33,11 +33,12 @@ namespace RoutingSample.Web public async Task RouteAsync(RouteContext context) { - if (context.RequestPath.StartsWith(_prefix, StringComparison.OrdinalIgnoreCase)) + var requestPath = context.HttpContext.Request.Path.Value ?? string.Empty; + if (requestPath.StartsWith(_prefix, StringComparison.OrdinalIgnoreCase)) { - if (context.RequestPath.Length > _prefix.Length) + if (requestPath.Length > _prefix.Length) { - var lastCharacter = context.RequestPath[_prefix.Length]; + var lastCharacter = requestPath[_prefix.Length]; if (lastCharacter != '/' && lastCharacter != '#' && lastCharacter != '?') { return; diff --git a/src/Microsoft.AspNet.Routing/RouteContext.cs b/src/Microsoft.AspNet.Routing/RouteContext.cs index 9224c504df..f0ef168bcc 100644 --- a/src/Microsoft.AspNet.Routing/RouteContext.cs +++ b/src/Microsoft.AspNet.Routing/RouteContext.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNet.Http; using System; +using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Routing { @@ -14,7 +14,6 @@ namespace Microsoft.AspNet.Routing { HttpContext = httpContext; - RequestPath = httpContext.Request.Path.Value; RouteData = new RouteData(); } @@ -22,8 +21,6 @@ namespace Microsoft.AspNet.Routing public bool IsHandled { get; set; } - public string RequestPath { get; private set; } - public RouteData RouteData { get diff --git a/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs b/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs index 64b382ea57..fd0f0b64d0 100644 --- a/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs +++ b/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs @@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Routing.Template public async virtual Task RouteAsync([NotNull] RouteContext context) { - var requestPath = context.RequestPath; + var requestPath = context.HttpContext.Request.Path.Value; if (!string.IsNullOrEmpty(requestPath) && requestPath[0] == '/') { requestPath = requestPath.Substring(1);