Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
when localhost
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Cache-Control: private Date: Tue, 18 Jun 2019 07:12:54 GMT Server: Microsoft-IIS/8.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Content-Length: 7 Content-Type: application/json; charset=utf-8 }


when publish
StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Cache-Control: private Date: Tue, 18 Jun 2019 04:38:35 GMT Server: Microsoft-IIS/8.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Content-Length: 3131 Content-Type: text/html }
Details

What I have tried:

double leaveacess = 0;
                               using (var client = new HttpClient())
                               {
                                   var empdetail = new Leave_Details() { empid = items.empid.ToString(), fromdate = d1, todate = d2, tabt = "1", jdis = "0" };
                                   //var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
                                   client.BaseAddress = new Uri("http://vkalra.org/WCF_SERVICE/RestServiceImpl.svc/");
                                   var postTask =  client.PostAsJsonAsync<Leave_Details>("Leave_Calculation", empdetail);
                                   //postTask.Wait();
                                    var result = postTask.Result;
                                    obj.error = result.ToString();
                                   if (result.IsSuccessStatusCode)
                                   {

                                       var readTask = result.Content.ReadAsStringAsync();
                                       string insertedStudent = readTask.Result.ToString();
                                       string[] splitval = insertedStudent.Split(',');
                                       leaveacess = Convert.ToDouble(splitval[0].ToString().Substring(1));
                                   }

                               }
Posted
Updated 17-Jun-19 21:28pm
v2
Comments
Maciej Los 18-Jun-19 2:24am    
Based on this piece of code and description we can NOT tell you why this happen...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900