如何在没有jquery

时间:2016-04-04 10:40:02

标签: c# soap asp.net-web-api

在这里我写了一个代码,其中我想要一个肥皂网方法,我知道如何点击web api但是新的肥皂应用程序,所以请让我知道如何在没有jquery的情况下调用

       using (HttpClient httpClientObj = new HttpClient())
        {
           httpClientObj.BaseAddress = new Uri("http://localhost:1172/");
            httpClientObj.DefaultRequestHeaders.Accept.Clear();
            httpClientObj.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage responseObj = default(HttpResponseMessage);
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(clsSSL.AcceptAllCertifications);
            responseObj = httpClientObj.PostAsJsonAsync("FairPriceShopRequestAck", val).Result;
            string responseReturnString = null;
            responseReturnString = responseObj.Content.ReadAsStringAsync().Result;
            if ((responseObj.IsSuccessStatusCode & responseObj.StatusCode == HttpStatusCode.OK))
            {
                dt = JsonConvert.DeserializeObject<string>(responseObj.Content.ReadAsStringAsync().Result);
            }
            else
            {
                //showMessageAjax(this, responseReturnString);
            }

            return "";
        }

获取错误http 500

0 个答案:

没有答案