简体   繁体   English

如何在ASP.NET 5中使用Uri和QueryString

[英]How to work with Uri and QueryString in ASP.NET 5

Previously in old MVC and WebApi Request types ( HttpRequestBase and HttpRequestMessage ) had property QueryString of type NameValueCollection . 以前,在旧的MVC和WebApi中,请求类型( HttpRequestBaseHttpRequestMessage )具有类型为NameValueCollection属性QueryString It represent key-value pairs in request's query string. 它代表请求的查询字符串中的键值对。 Now in AspNet5 HttpRequest has QueryString property which type is QueryString struct. 现在,在AspNet5中,HttpRequest具有QueryString属性,该类型为QueryString结构。 But it's just a wrapper around a string value. 但这只是一个字符串值的包装。 It doesn't have values, indexer, IEnumerable. 它没有值,索引器,IEnumerable。 Nothing. 没有。

How is it supposed to work with values in QS? 如何使用QS中的值?

Also similar question about working with URI. 有关使用URI的类似问题。 Previously we had HttpRequestBase.Url and HttpRequestMessage.RequestUri of type System.Uri . 以前我们有类型为System.Uri HttpRequestBase.UrlHttpRequestMessage.RequestUri Now just strings (PathBase, Path, QueryString). 现在只是字符串(PathBase,Path,QueryString)。 What's wrong with System.Uri? System.Uri有什么问题? Why is it abandoned? 为什么要放弃?

In beta-3, the HttpRequest also has a Query property, which is a new type, IReadableStringCollection . 在beta-3中, HttpRequest还具有Query属性,它是一种新类型IReadableStringCollection This behaves almost identically to the NameValueCollection , as near as I can tell. 据我所知,它的行为几乎与NameValueCollection相同。 I'm using it my controllers through Request.Query . 我通过Request.Query控制器中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 URI QueryString JsonSerializerSettings和Asp.Net核心 - URI QueryString JsonSerializerSettings and Asp.Net Core 如何修改 asp.net 核心中中间件的表单和查询字符串值? - How to modify form & querystring values at middleware in asp.net core? 如何使用 ASP.NET Core 从查询字符串中读取值? - How to read values from the querystring with ASP.NET Core? 如何在ASP.NET Core中使用HttpContextAccessor读取URI参数 - How to read URI Parameters using HttpContextAccessor in ASP.NET Core 如何在SignalR(Asp.net Core)中的OnDisconnected中修复Context.QueryString的null? - How can I fix the null of Context.QueryString in the OnDisconnected in SignalR (Asp.net Core)? 如何在 asp.net 核心 3.1 mvc 中保留所有查询字符串值? - How do I persist all querystring values in asp.net core 3.1 mvc? 如何修复 Invalid URI:在 asp.net core 问题中无法确定 URI 的格式 - How to fix Invalid URI: The format of the URI could not be determined in asp.net core problem Append QueryString 到 asp.net 核心锚助手标签中的 href - Append QueryString to href in asp.net core Anchor Helper Tag Asp.Net Core Querystring参数未被解码 - Asp.Net Core Querystring Parameters not being decoded 查询字符串与正文中的 ASP.NET 日期时间序列化 - ASP.NET DateTime Serialization in QueryString vs Body
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM