我怎样才能通过“&”转换为查询字符串值

发布于 2024-11-04 06:55:20 字数 372 浏览 5 评论 0原文

我的应用程序中有一个带有以下 URL 的链接:

 http://www.mysite.com/test?group=MyGroup

问题是其中一个组称为 A 组和 A 组。 B

当我尝试这个并在服务器端解析它(通过 Request.QueryString["Group"])时,

 http://www.mysite.com/test?group=Group A & B

我得到

group='Group A ' (因为 &)

我如何更改我的 URL,以便它可以用“&”处理值在他们里面。

i have a link in my app with the following URL:

 http://www.mysite.com/test?group=MyGroup

the issue is one of the groups is called Group A & B

when i try this and parse it on the serverside (through Request.QueryString["Group"])

 http://www.mysite.com/test?group=Group A & B

i get

group='Group A ' (because of the &)

how can i change my URL so it can deal with values with "&" inside of them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滿滿的愛 2024-11-11 06:55:20

使用 URLEncode 方法使文本对于查询字符串来说是安全的。

var url = "http://www.mysite.com/test?group=" + 
           System.Web.HttpServerUtility.UrlEncode("Group A & B");

Use the URLEncode method to make your text safe for a querystring.

var url = "http://www.mysite.com/test?group=" + 
           System.Web.HttpServerUtility.UrlEncode("Group A & B");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文