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,
4
  • 1
    can you show us the code you are using Commented Jun 22, 2012 at 15:09
  • 1
    What? There is only one kind of URL encoding. Commented Jun 22, 2012 at 15:10
  • This has already been answered here: stackoverflow.com/questions/1812473/… Commented Jun 22, 2012 at 15:11
  • code and data that i am sending is added. Commented Jun 22, 2012 at 15:42

1 Answer 1

1

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

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

2 Comments

am sending data like this RUNTIME………..: 2h:13m:15s RELEASE SIZE……: 16,2GB VIDEO CODEC…….: x264, 2pass having some spacial character.
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 <url>?runtime=133&releasesize=16.2&code=x264? Where 133 = (2*60)+13.

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.