HttpWebRequest and QueryString

  • Thread starter Thread starter Chris Gallucci
  • Start date Start date
C

Chris Gallucci

I'm trying to execute a "POST" with a HttpWebRequest object that has a Uri containing a QueryString. The QueryString is being
Url-Encoded by the object. The server receiving the "POST" is not Url-Decoding the QueryString and I have no control over
this behavior.

Can someone show me how to prevent the Url-Encoding of the HttpWebRequest.RequestUri?

Thanks,

ChrisG
 
Chris,

By default, I believe the Uri class escapes the characters in the query
string. In order to get around this, create an instance of the Uri
yourself, and use the constructor with a boolean parameter. Pass true for
this and it will not escape the query string.

Then, pass this Uri instance to the static Create method on the
WebRequest class.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Chris Gallucci said:
I'm trying to execute a "POST" with a HttpWebRequest object that has a Uri
containing a QueryString. The QueryString is being
Url-Encoded by the object. The server receiving the "POST" is not
Url-Decoding the QueryString and I have no control over
 
Bingo!

I wasn't equating "escaping" with "encoding".

Thanks, Nicholas.

(P.S. Sorry to the mods; I actually meant to post this in .clr)

ChrisG
 
Back
Top