Reputation: 36138
I have an HttpHandler that reads the parameters from the request URL by simply using context.Request["param1"]. The thing is that my website is xHTML compliant so all links are encoded. So I have a link in the format of: http://mydomain.com/?param1=a¶m2=b.
The problem is that Request["param2"] is not recognized. Instead it thinks the second parameter is "amp;param2". It does not realize that the & is representing & in the URL. How would I tell "Request" that the links are expected to be xHTML compliant?
Upvotes: 3
Views: 3361
Reputation: 1350
You need to UrlEncode your links, not HTMLEncode.
The first one gives & = %26
while the latter (the one you're using) gives & = &
and the handler is breaking the parameters by the first & in &
Upvotes: 5
Reputation: 11773
The ampersand in your url that separates your GET (ie querystring/request) parameters still needs to be an '&'. If you're displaying an ampersand in actual XHTML, that's when you will use the XHTML encoding. XHTML encoding an ampersand for use as a parameter separator in a URL will not be recognized as such.
Upvotes: 0
Reputation: 44941
You want to use Request.QueryString
, not Request.
For example:
context.Request.QueryString["param1"]
context.Request.QueryString["param2"]
Upvotes: 2