System.Net.Http.HttpResponseMessage.Content.get returned null.
My code as follows[HttpPost]
public ActionResult UploadFiles(HttpPostedFileBase[] files)
{
//Ensure model state is valid
if (ModelState.IsValid)
{ //iterating through multiple file collection
foreach (HttpPostedFileBase file in files)
{
//Checking file is available to save.
if (file != null)
{
var InputFileName = Path.GetFileName(file.FileName);
var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + InputFileName);
//Save file to server folder
file.SaveAs(ServerSavePath);
//assigning file uploaded status to ViewBag for showing message to user.
ViewBag.UploadStatus = files.Count().ToString() + " files uploaded successfully.";
var response = new HttpResponseMessage();
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri("https://ca-usa.paradatec-cloud.com/api/");
response = httpClient.PostAsync(@"api/job/UploadFiles", new StringContent(string.Empty)).Result;
// GetTestPDF
}
var whatisThis = response.Content.ReadAsStringAsync().Result;
return new FileContentResult(Convert.FromBase64String(response.Content.ReadAsStringAsync().Result), "application/pdf");
}
}
}
return View();
}
When i run the above code shows error in below line as follows
var whatisThis = response.Content.ReadAsStringAsync().Result;
System.Net.Http.HttpResponseMessage.Content.get returned null.
please let me know how to solve this error