Removing RouteContext.RequestPath and calculating it from HttpContext as needed.

This commit is contained in:
Pranav K 2014-06-09 11:17:28 -07:00
parent a499d4a92a
commit a1fe088d3a
3 changed files with 6 additions and 8 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);