1. 程式人生 > 實用技巧 >窗體呼叫第三方介面

窗體呼叫第三方介面

一.

        private void button1_Click(object sender, EventArgs e)
        {
            string url = "localhost";
            byte[] responseArray = null;
            using (WebClient webClient = new WebClient())
            {
                webClient.Headers.Add("jsonStr", "");
                NameValueCollection postValues 
= new NameValueCollection(); responseArray = webClient.UploadValues(url, postValues); } string response = Encoding.UTF8.GetString(responseArray); if (!string.IsNullOrEmpty(response) && !response.Equals("null")) {
//result = JsonConvert.DeserializeObject<BaseElseResut>(response); //if (result != null && result.Data != null && result.Data.success) //{ // Response.Write("<script language=javascript>window.location.href='" + result.Data.Reason + "';</script>");
//} //else //{ // Response.Write("<script>alert('" + result.Data.Reason + "');</script>"); //} } }

二.