You need to encode your values by calling Server.UrlEncode
before putting them into the URL.
If your values are in an array, you'll need to use a loop. If you want precise instructions, you'll need to show us your current code.
You need to encode your values by calling Server.UrlEncode
before putting them into the URL.
If your values are in an array, you'll need to use a loop. If you want precise instructions, you'll need to show us your current code.
The ampersand (&) is a special character in a url. So the above URL is being interprested as www.google.com with three arguments: 2 Departments and a Finance.
Try using:
System.Web.HttpUtility.UrlEncode(string url)
to encode the URL.
The values in the query string should be url encoded. Now there is no way to determine the difference between the &
characters that separate the value pairs and the &
character inside one of the values. Also, eventhough most browsers will accept spaces in an URL, that is invalid according to the standard.
In the value Education & Finance
you have to encode the spaces as +
or %20
, and the &
character as %26
so that it becomes Education%20%26%20Finance
.
So the correct URL should be:
www.google.com?Department=Education%20%26%20Finance&Department=Health