[英]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中,请求类型(
HttpRequestBase
和HttpRequestMessage
)具有类型为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.Url
和HttpRequestMessage.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.