Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:32:43+00:00 2026-05-27T20:32:43+00:00

Running the below code with Fiddler shows that plus signs are getting converted to

  • 0

Running the below code with Fiddler shows that plus signs are getting converted to a white space char of some sort. What encoding should I use to keep the data from being converted? I would like to keep the plus signs, etc.

EDIT: Updated code example

string postData = "test1=test+plussign&test2=another++twoplussigns";
private static byte[] EncodePostData(string postData)
{
    StringBuilder sb = new StringBuilder();

    string[] pairs = postData.Split('&');
    foreach (string pair in pairs)
    {
        string key = Uri.EscapeDataString(pair.Split('=')[0]);
        string value = Uri.EscapeDataString(pair.Split('=')[1]);

        sb.AppendFormat("{0}={1}&",key, value);
    }
    sb.Remove(sb.Length - 1, 1);

    return HttpUtility.UrlEncodeToBytes(sb.ToString());
}

And here is the calling method

byte[] data = EncodePostData(postData);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.3) Gecko/2008092510 Ubuntu/8.04 (hardy) Firefox/3.03";
request.CookieContainer = cookies;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
ServicePointManager.Expect100Continue = false;

Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();

HttpWebResponse Response = (HttpWebResponse)request.GetResponse();
Response.Close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:32:43+00:00Added an answer on May 27, 2026 at 8:32 pm

    Since your variable is called postData, I’m going to assume you’re making a HTTP POST to a web server.

    Wikipedia’s summary of the rules for HTTP POST is:

    When a web browser sends a POST request from a web form element, the
    default Internet media type is “application/x-www-form-urlencoded”.
    This is a format for encoding key-value pairs with possibly duplicate
    keys. Each key-value pair is separated by an ‘&’ character, and each
    key is separated from its value by an ‘=’ character. Keys and values
    are both escaped by replacing spaces with the ‘+’ character and then
    using URL encoding on all other non-alphanumeric characters.

    That is, the default interpretation of '+' in a HTTP POST body is an encoded ' ' character. You need to escape your data properly, by calling Uri.EscapeDataString or HttpUtility.UrlEncode.

    Uri.EscapeDataString("test+PlusSigns"); // returns "test%2BPlusSigns"
    

    Alternatively, use HttpUtility.UrlEncodeToBytes and write the resulting bytes directly to the request stream (without using a StreamWriter).

    (Note that if you are sending key/value pairs, you need to escape each key and value independently, then join them with '=' and '&' characters.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running the code below and getting an empty chart using Flot/jQuery. Ideally what
I was running some code & I wasn't getting any errors, but the row
I am running the code below in some if/else statements, I have a weird
I am getting access violation exceptions when running the code below when the CertFreeCertificateContext
When running the below code a type is never returned, despite there being a
Hello friends i am running code given below which contains the setLogTimeEntery function and
I am getting he following Exception while running my Quartz Schdular program. Below is
In the below code the fputs(...) throws an assert when running on Windows Server
I get this message when running the code below: There is an error in
As per the below Code, I am getting every single details of the program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.