Здравствуйте, я пытаюсь использовать оставшийся веб-сервис и выставить его в формате chtml, но я продолжаю получать эту ошибку, когда я запускаю свое приложение, и я не понимаю его.это из-за отсутствующей библиотеки или зависимости?
Контроллер отсутствия:
using ProjectWeb.Models;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Mvc;
namespace ProjectWeb.Controllers
{
public class AbsenceController : Controller
{
// GET: Absence
public ActionResult Index()
{
HttpClient Client = new System.Net.Http.HttpClient();
Client.BaseAddress = new Uri("http://localhost:18080/PiDev-web/rest/absence/");
Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = Client.GetAsync("all").Result;
if (response.IsSuccessStatusCode)
{
ViewBag.result = response.Content.ReadAsAsync<IEnumerable<Absence>>().Result;
///ViewBag.result1 = response.Content.ReadAsStringAsync().Result;
}
else
{
ViewBag.result = "error";
}
return View("index");
}
// GET: Absence/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: Absence/Create
public ActionResult Create()
{
return View();
}
// POST: Absence/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Absence/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: Absence/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Absence/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: Absence/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
}
Мой index.chtml:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>index</title>
</head>
<body>
<br />
<h3>
@Html.ActionLink("Ajouter Absence ", "Create")
</h3>
<hr />
<table class="table">
<tr>
<th>ID</th>
<th>Nom</th>
<th>Action</th>
</tr>
@foreach (var h in ViewBag.result)
{
<tr>
<td>@h.idAbsence</td>
<td>@h.cause</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = h.idAbsence }) |
@Html.ActionLink("Details", "Details", new { id = h.idAbsence }) |
@Html.ActionLink("Delete", "Delete", new { id = h.idAbsence })
</td>
</tr>
}
</table>
</body>
</html>
, и когда я запускаю его, нажимая на просмотр в браузере, я получаю эту ошибку enterописание изображения здесь
и когда я нажимаю на него, ошибка вызывается:
ViewBag.result =response.Content.ReadAsAsync<IEnumerable<Absence().Result;
пожалуйста, если вы знакомы с этой ошибкой, помогите мне