2

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.

leora
  • 188,729
  • 360
  • 878
  • 1,366

1 Answers1

4

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");
Bob
  • 97,670
  • 29
  • 122
  • 130