0

What url encoding a web browser uses while submitting data to server? with my application i use HttpUtility.UrlEncode(string data) but do not get result as i get with web browser.

My application submit some text data to forum.

When i am submitting data with web browser (Google Chrome) the exact text i can see submitted to server but when i am submitting using my application it showing some character different.

So is this necessary to submit any data to server must be url encoded?

---Edit---

        data = HttpUtility.UrlEncode(textBox1.Text);

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.CookieContainer = cookieContainer;
        request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5";
        request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
        request.Headers.Add("Accept-Charset", "ISO-8859-2,utf-8;q=0.7,*;q=0.7");
        request.Headers.Add("Accept-Encoding", "gzip, deflate");
        request.Headers.Add("Accept-Language", "pl,en-us;q=0.7,en;q=0.3");
        request.Method = "POST";
        byte[] byteArray = new byte[256];
        ASCIIEncoding ascii = new ASCIIEncoding();
        byteArray = ascii.GetBytes(data);     

        request.ContentType = "application/x-www-form-urlencoded";
        request.ContentLength = byteArray.Length;
        Stream dataStream = request.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();

and data in textbox1 is like this.

¦=¦=¦¦=¦=¦
RUNTIME………..: 2h:13m:15s
RELEASE SIZE……: 16,2GB
VIDEO CODEC…….: x264, 2pass,
Prince123
  • 97
  • 1
  • 8

1 Answers1

1

You generally only have to URLEncode if you want to include a URL reserved charatcer (?, &, etc.) in a url parameter.

Liam
  • 27,717
  • 28
  • 128
  • 190
  • am sending data like this RUNTIME………..: 2h:13m:15s RELEASE SIZE……: 16,2GB VIDEO CODEC…….: x264, 2pass having some spacial character. – Prince123 Jun 22 '12 at 15:26
  • nothing jumping out at me in that, that said it's a pretty ugly url? Wouldn't it make more sense to send something like ?runtime=133&releasesize=16.2&code=x264? Where 133 = (2*60)+13. – Liam Jun 25 '12 at 10:02