Unity's WWW mainly supports the get and post methods in HTTP. After the get method attaches the request to the URL, the POST method submits the request in form.
The following is information about the unity client:
Using unityengine; using system. collections; public class webmanger: monobehaviour {// use this for initialization void start () {}// update is called once per frame void Update () {} string m_string = "nothing"; void ongui () {GUI. begingroup (New rect (300, screen. height * 0.5f-1,500,200), ""); GUI. label (New rect (10, 10,), m_string); If (GUI. button (New rect (,), "Get Data") {startcoroutin E (igetdata ();} If (GUI. button (New rect (,), "Post Data") {startcoroutine (ipostdata ();} GUI. endgroup ();} ienumerator igetdata () {WWW = new WWW ("http: // localhost: 12063/default. aspx? Name = hometown1986 "); yield return WWW; // wait for the response from the Web server if (www. Error! = NULL) {m_string = www. error; yield return NULL;} m_string = www. text;} ienumerator ipostdata () {system. collections. hashtable headers = new hashtable (); headers. add ("Content-Type", "application/X-WWW-form-urlencoded "); // Save the HTTP header // Save the string as a byte array string data = "Pwd = chinajoy"; byte [] bt = system. text. utf8encoding. utf8.getbytes (data); www WWW = new WWW ("http: // localhost: 12063/default. aspx ", BT, headers); yield Return WWW; If (www. Error! = NULL) {m_string = www. error; yield return NULL;} m_string = www. Text ;}}
Below is how C # handles the server:
Public partial class _ default: system. Web. UI. Page {protected void page_load (Object sender, eventargs e) {// get If (request. querystring ["name"]! = NULL) {response. write ("name:" + request. querystring ["name"]. tostring ();} // post response. write ("Password:" + request. form ["PWD"]); response. end ();}}