我有我的模型傳遞給視圖一個奇怪的問題MVC 3無法將字符串作爲View的模型傳遞?
控制器
[Authorize]
public ActionResult Sth()
{
return View("~/Views/Sth/Sth.cshtml", "abc");
}
查看
@model string
@{
ViewBag.Title = "lorem";
Layout = "~/Views/Shared/Default.cshtml";
}
錯誤消息
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
爲什麼我不能傳遞一個簡單的字符串作爲模型?
你爲什麼使用這些相對路徑?使用這個:'View(「sth」,null,「abc」);' – gdoron 2012-03-21 10:38:27