3

I am trying to send a simple HTTP request like this:

var client = new WebClient();                
string myString="this is the string i want to send";
message = client.DownloadString("http://www.viralheat.com/api/sentiment/review.xml?text=" + myString + "&api_key="+currentKey);

but some of the strings I send includes # or & or such characters, so I want to encode the string first before sending it, because it throws an error if it includes these special characters without being encoded.

2 Answers 2

6

Call Uri.EscapeDataString.
Unlike HttpUtility, this works on the client profile too.

Sign up to request clarification or add additional context in comments.

Comments

5

Use HttpUtility.UrlEncode

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.