Asp.net core Asp.Net核心中的Request.Url.PathAndQuery

Asp.net core Asp.Net核心中的Request.Url.PathAndQuery,asp.net-core,Asp.net Core,我从Asp.Net框架转移到Asp.Net核心。Asp.Net Core中的Request.Url.PathAndQuery的替换属性或等效属性是什么?您需要使用HttpContext分别访问Url路径和查询字符串 在控制器中: var path = HttpContext.Request.Path; var query = HttpContext.Request.QueryString; var pathAndQuery = path + query; 要获取HttpContext,请参考尝

我从Asp.Net框架转移到Asp.Net核心。Asp.Net Core中的
Request.Url.PathAndQuery
的替换属性或等效属性是什么?

您需要使用
HttpContext
分别访问Url路径和查询字符串

在控制器中:

var path = HttpContext.Request.Path;
var query = HttpContext.Request.QueryString;
var pathAndQuery = path + query;

要获取
HttpContext
,请参考尝试此项,它也是我的工作表单

using Microsoft.AspNetCore.Http;    
using Microsoft.AspNetCore.Http.Features;   
/// <summary>
/// Gets the raw target of an HTTP request.
/// </summary>
/// <returns>Raw target of an HTTP request</returns>    
/// <remarks>   
/// ASP.NET Core manipulates the HTTP request parameters exposed to pipeline    
/// components via the HttpRequest class. This extension method delivers an untainted   
/// request target. https://tools.ietf.org/html/rfc7230#section-5.3 
/// </remarks>  
public static string GetRawTarget(this HttpRequest request) 
{       
    var httpRequestFeature = request.HttpContext.Features.Get<IHttpRequestFeature>();       
    return httpRequestFeature.RawTarget;    
}
使用Microsoft.AspNetCore.Http;
使用Microsoft.AspNetCore.Http.Features;
/// 
///获取HTTP请求的原始目标。
/// 
///HTTP请求的原始目标
///    
///ASP.NET Core处理向管道公开的HTTP请求参数
///通过HttpRequest类的组件。这个扩展方法提供了一个不受污染的
///请求目标。https://tools.ietf.org/html/rfc7230#section-5.3 
///   
公共静态字符串GetRawTarget(此HttpRequest请求)
{       
var httpRequestFeature=request.HttpContext.Features.Get();
返回httpRequestFeature.RawTarget;
}
我正在创建扩展方法或请求对象