Url Encoding with Multiple Query String Parameters
14,646
Solution 1
Use HttpUtility.UrlEncode
, I bet it will work like a charm.
Read this article for more information.
Solution 2
The biggest issue is that you're encoding the whole query string. You need to encode the individual components, then concatenate them together.
Author by
V.B
Updated on June 05, 2022Comments
-
V.B almost 2 years
In my c# code I am encoding my Url that has multiple query strings. When at the receiver end I try to read back the query strings I get the null values (query string parameter is not found) reason being encoding changes &querystringparameter to &querystringparam. How to get around this.
Response.Redirect(HttpUtility.HtmlEncode("Add.aspx?ID=" + 1 + "&cid="+ 8 + "&jid=" +9));
On the add.aspx page i get the url as "add.aspx?id=1&sid=3&jid=9"
-
V.B over 11 yearsyou mean where I read the query string or instead of HttpUtility.HtmlEncode?
-
Lajos Arpad over 11 yearsI have edited my answer, check out the link, it should be helpful.