1

I am creating queryString from Javacript like below

serialize = function(obj) {
  var str = [];
  for(var p in obj)
    if (obj.hasOwnProperty(p)) {
      str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
    }
  return str.join("&");
}

Js solution here

I am passing a parameter which contains '&' (ampersand) character like below:

activityCategory=Cruises, Sailing & Water Tours

url encoded value:

activityCategory=Cruises%2C%20Sailing%20%26%20Water%20Tours

But

Request.QueryString["activityCategory"]

is returning Cruises, Sailing only. How can I get full value of activityCategory

Community
  • 1
  • 1
Prem Parihar
  • 1,070
  • 2
  • 9
  • 15
  • 3
    The approach you have is correct. Something must be breaking it between you encoding it and it reaching the Request object on the server. – Quentin Jan 10 '15 at 16:57
  • How exactly are you checking the value on the server? – Pointy Jan 10 '15 at 16:58
  • I am checking through debugging `ActivityCategory = SecurityManager.Encoder.HtmlEncode(Request.QueryString["activityCategory"] ?? Request.Form["activityCategory"])` – Prem Parihar Jan 10 '15 at 17:03
  • 1
    If it is interpreting it incorrectly, `Request.QueryString.Keys` should contain " Water Tours". Can you check that? – Rhumborl Jan 10 '15 at 17:16
  • There is no " Water Tours" key. But I can see null after "ActivityCategory" and than other keys – Prem Parihar Jan 10 '15 at 17:22
  • 1
    Please check the _actual_ value of `Request.QueryString["activityCategory"]` and not the result you get after passing it through `SecurityManager.Encoder.HtmlEncode()` (whatever that is). There could very well be a bug in that HtmlEncode() method. – JLRishe Jan 10 '15 at 17:38
  • I checked again and I can see wrong value is returning from `Request.QueryString["activityCategory"]`. – Prem Parihar Jan 10 '15 at 20:14

0 Answers0