<summary>
Send Request
</summary>
<param name= "Uri" > Request address </param>
<param name= "jsonstr" >json data </param>
<returns></returns>
public static string Clientrequest (String Uri, String jsonstr)
{
Try
{
string serviceaddress = Uri;
var HttpRequest = (HttpWebRequest) httpwebrequest.create (serviceaddress);
Httprequest.method = "POST";
Httprequest.contenttype = "Application/json";
Httprequest.proxy = null;
Httprequest.useragent = "mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) gecko/20100101 firefox/11.0 ";
Httprequest.useragent = "mozilla/5.0 (Windows; U Windows NT 6.1; ZH-CN; rv:1.9.2.13) gecko/20101203 firefox/3.6.13 ";
HTTPREQUEST.HEADERS.ADD ("Accept-language", "zh-cn,en-us;q=0.8,zh-hk;q=0.6,ja;q=0.4,zh;q=0.2");
httprequest.accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
Servicepointmanager.servercertificatevalidationcallback = delegate {return true;};
Servicepointmanager.securityprotocol = SECURITYPROTOCOLTYPE.SSL3;
using (var dataStream = new StreamWriter (Httprequest.getrequeststream ()))
{
Datastream.write (JSONSTR);
Datastream.flush ();
Datastream.close ();
}
var HttpResponse = (HttpWebResponse) httprequest.getresponse ();
using (var dataStream = new StreamReader (Httpresponse.getresponsestream ()))
{
var result = Datastream.readtoend ();
return result;
}
}
catch (Exception ex)
{
Return "{\" error\ ": \" "+ Ex. Message + "\"} ";
}
}
. NET sends requests, carrying JSON data