Jrsahoo
Jrsahoo

Reputation: 41

use of "application/x-www-form-urlencoded" in HTTP Post method

What is the meaning of

ContentType = "application/x-www-form-urlencoded" in HTTP Post method..??

my code is

         Uri url = new Uri(" http://blah/blah/blah...json");

         HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);

         webRequest.Method = "POST";

         webRequest.ContentType = "application/x-www-form-urlencoded";

Upvotes: 0

Views: 2321

Answers (2)

Agung Pratama
Agung Pratama

Reputation: 3784

I have been using ContentType = "application/x-www-form-urlencoded" in particular project. What I know is, it is the scheme that is used, so the POST parameters you are sending to the server are in the form-urlencoded. For example, if you send the parameter key-value like below: name=Agung id=121

then, when you send the request, the POST body will be like encoded to be like this: name=Agung&id=121

When you are setting ContentType = "application/x-www-form-urlencoded", then the server will know how to parse the Body parameter you are sending.

Hope it will help

Upvotes: 3

Yogesh Prajapati
Yogesh Prajapati

Reputation: 4870

This is used for Security purpose.

you can get more help here.

Upvotes: -1

Related Questions