查询字符串值为"&"

TSS*_*S22 3 c# asp.net encoding decoding

我有一个查询字符串

www.google.com?Department=Education & Finance&Department=Health
Run Code Online (Sandbox Code Playgroud)

我有这些作为li标签,他们的查询字符串是这样的:

  • 教育与金融
  • 健康

现在的问题是当我在做NamevalueCollection并获得所有键值时:它给我的只是教育,而不是财务......

知道怎么解决这个问题吗?

SLa*_*aks 8

您需要在将值Server.UrlEncode放入URL之前通过调用对值进行编码.

如果您的值在数组中,则需要使用循环.如果您需要精确的说明,则需要向我们展示您当前的代码.


Jef*_*nby 6

&符号(&)是网址中的特殊字符.因此,上述网址被视为www.google.com的三个参数:2个部门和财务部门.

尝试使用:

System.Web.HttpUtility.UrlEncode(string url) 
Run Code Online (Sandbox Code Playgroud)

编码URL.