Sourav Kumar Das

Sourav Kumar Das

  • 494
  • 2.5k
  • 166.5k

WEB API consuming in MVC is throwing an error?

Dec 31 2019 1:26 AM
Hi All,
 
I have a question in WEB Api consuming in MVC is throwing an error, like "Time outs are not supported on this stream"
 
  1. public async Task<ActionResult> InsertVendorDetails(Vendor V)  
  2.         {  
  3.             Session["UserId"] = "1001";  
  4.             if (V.FirstName != null && V.LastName != null && V.MobileNo != null && V.UserName != null && V.Address != null && V.IDProof != null && V.EmailId != null && V.Password != null)  
  5.             {  
  6.                 HttpClient client = new HttpClient();  
  7.                 client.BaseAddress = new Uri(Baseurl);  
  8.                 //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));  
  9.                 client.DefaultRequestHeaders.Accept.Clear();  
  10.                 V.CreatedBy = Session["UserId"].ToString();  
  11.   
  12.                 HttpResponseMessage response = await client.PostAsJsonAsync("NewVendorRegistration", V);  
  13.                 if (response.IsSuccessStatusCode == true)  
  14.                 {  
  15.                     var vendorresponse = response.Content.ReadAsStringAsync().Result;  
  16.                     var StatusCode = JObject.Parse(vendorresponse)["StatusCode"].ToString();  
  17.                     if (StatusCode == "1")  
  18.                     {  
  19.                         return RedirectToAction("GetVendor""SmartParkingApplication");  
  20.                     }  
  21.   
  22.                     else  
  23.                     {  
  24.                         var Response = JObject.Parse(vendorresponse)["Response"].ToString();  
  25.                         ModelState.AddModelError(string.Empty, Response.ToString());  
  26.                     }  
  27.                 }  
  28.                 else  
  29.                 {  
  30.                     ModelState.AddModelError(string.Empty, "Server Error.Please contact administrator.");  
  31.                 }  
  32.                 return View();  
  33.             }  
  34.             return View();  
  35.         } 
 At Line no : 12
 
while running in postman it's consuming correctly but in mvc it's not running.
 
If there's a solution please let me know it as soon as possible.

Answers (3)