我想顯示所有停車位的詳細資訊(ID 名稱 狀態),但我的視圖看不到我的模型類
控制器:
public async Task<IActionResult> ParkingFinder()
{
var parking = new ParkingDto();
using (var client = new HttpClient())
{
//Passing service base url
client.BaseAddress = new Uri(Baseurl);
//Sending request to find web api REST service resource GetCompanyParkingById using HttpClient
int id = 5;
HttpResponseMessage result = await client.GetAsync($"Parking/GetCompanyParkingById/{id}");
//Checking the response is successful or not which is sent using HttpClient
if (result.IsSuccessStatusCode)
{
//Storing the response details recieved from web api
parking = result.Content.ReadAsAsync<ParkingDto>().Result;
}
}
return View(parking);
}
然后我想在這里查看'ParkingDto'類中的'parking':
@using MVC.SmartParkingSystem.Models.ParkingDto;
但我收到此錯誤:
命名空間“MVC.SmartParkingSystem.Models”中不存在型別或命名空間名稱“ParkingDto”(您是否缺少程式集參考?)
解決方案瀏覽器:
uj5u.com熱心網友回復:
我使用@model 而不是@using,因此問題解決了:
@model SmartParkingSystem.Entity.ParkingDto;
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/467513.html
標籤:asp.net-mvc 剃刀