Tôi có một vấn đề xa lạ với mô hình của tôi truyền cho XemMVC 3 Không thể chuyển chuỗi dưới dạng mô hình của Chế độ xem?
khiển
[Authorize]
public ActionResult Sth()
{
return View("~/Views/Sth/Sth.cshtml", "abc");
}
Xem
@model string
@{
ViewBag.Title = "lorem";
Layout = "~/Views/Shared/Default.cshtml";
}
Thông báo lỗi
The view '~/Views/Sth/Sth.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Sth/Sth.cshtml
~/Views/Sth/abc.master //string model is threated as a possible Layout's name ?
~/Views/Shared/abc.master
~/Views/Sth/abc.cshtml
~/Views/Sth/abc.vbhtml
~/Views/Shared/abc.cshtml
~/Views/Shared/abc.vbhtml
Tại sao tôi không thể truyền một chuỗi đơn giản làm mô hình?
Tại sao bạn sử dụng các đường dẫn tương đối đó? sử dụng này: 'View (" Sth ", null," abc ");' – gdoron