Removing RouteContext.RequestPath and calculating it from HttpContext as needed.
This commit is contained in:
parent
a499d4a92a
commit
a1fe088d3a
|
|
@ -33,11 +33,12 @@ namespace RoutingSample.Web
|
||||||
|
|
||||||
public async Task RouteAsync(RouteContext context)
|
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 != '?')
|
if (lastCharacter != '/' && lastCharacter != '#' && lastCharacter != '?')
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
// 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.
|
// 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 System;
|
||||||
|
using Microsoft.AspNet.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Routing
|
namespace Microsoft.AspNet.Routing
|
||||||
{
|
{
|
||||||
|
|
@ -14,7 +14,6 @@ namespace Microsoft.AspNet.Routing
|
||||||
{
|
{
|
||||||
HttpContext = httpContext;
|
HttpContext = httpContext;
|
||||||
|
|
||||||
RequestPath = httpContext.Request.Path.Value;
|
|
||||||
RouteData = new RouteData();
|
RouteData = new RouteData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,8 +21,6 @@ namespace Microsoft.AspNet.Routing
|
||||||
|
|
||||||
public bool IsHandled { get; set; }
|
public bool IsHandled { get; set; }
|
||||||
|
|
||||||
public string RequestPath { get; private set; }
|
|
||||||
|
|
||||||
public RouteData RouteData
|
public RouteData RouteData
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Routing.Template
|
||||||
|
|
||||||
public async virtual Task RouteAsync([NotNull] RouteContext context)
|
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] == '/')
|
if (!string.IsNullOrEmpty(requestPath) && requestPath[0] == '/')
|
||||||
{
|
{
|
||||||
requestPath = requestPath.Substring(1);
|
requestPath = requestPath.Substring(1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue