sending base64 string using HttpWebRequest in c# convert "+" to white space issue
<p>i convert an image to base64 string to upload through HttpWebRequest in c#.on server side when i receive base64 string the "+" signs have been converted to white spaces" ". it give me error to convert this base64 string to byte array.i do not want to make any change on server side(in web services). i want to resolve this issues on client side.my client side code is as follow.</p>

<p>//////////////////</p>

<p>WSManagerResult wsResult = new WSManagerResult();</p>

<pre><code>        try
        {
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(serviceURL);
            req.Method = "POST";
            req.ProtocolVersion = HttpVersion.Version11;
            req.ContentType = "application/x-www-form-urlencoded";
            //  req.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
            // req.CookieContainer = new CookieContainer();


            string content = string.Empty;
            foreach (KeyValuePair&lt;string, string&gt; entry in paramDic)
            {
</code></pre>

<p>// entry.Value is  a base 64 string gene rated from image</p>

<pre><code>             content = content + entry.Key + "=" + entry.Value + "&amp;&amp;";
            }
            content = content.TrimEnd('&amp;'); // input parameter if u have more that one //a=b&amp;dd=aa               
            req.ContentLength = content.Length;
            // req = URLEncode(content);
            Stream wri = req.GetRequestStream();


            byte[] array = Encoding.ASCII.GetBytes(content);
            if (array.Length &gt; 0)
                wri.Write(array, 0, array.Length);
            wri.Flush();
            wri.Close();
            WebResponse rsp = (HttpWebResponse)req.GetResponse();


            byte[] b = null;
            using (Stream stream = rsp.GetResponseStream())
            using (MemoryStream ms = new MemoryStream())
            {
                int count = 0;
                do
                {
                    byte[] buf = new byte[1024];
                    count = stream.Read(buf, 0, 1024);
                    ms.Write(buf, 0, count);
                } while (stream.CanRead &amp;&amp; count &gt; 0);
                b = ms.ToArray();
            }
            wsResult.result = Encoding.ASCII.GetString(b);
        }
        catch (Exception e)
        {
            clsException.ExceptionInstance.HandleException(e);
            wsResult.error = e.Message;
        }


        return wsResult;
</code></pre>

<p>All the "+" signs in above base64 string are converted in to " " white spaces.which causes the issue as describe above.</p>

<p>Please help me to resolve this issue.</p>

<p>Regards</p>

<p>shah Khalid</p>
