我有一个强类型的部分视图,应该显示用户登录的帐户名称:
@model MyNamespace.Models.AccountNameViewModel
@if (Request.IsAuthenticated)
{
@Html.Action("AccountName", "AccountNameController", Model)
Logged in to @Model.AccountName
}
我有一个控制器:
public class AccountNameController : Controller
{
public ActionResult Index()
{
return View();
}
[ChildActionOnly]
public ActionResult AccountName(AccountNameViewModel model)
{
... Do somthing with the repository to populate the model
return PartialView(model);
}
}
我想要做的是添加一个共享的局部视图,显示用户登录的帐户的名称。我得到的是以下错误:
The controller for path '/ParentViewPath/' was not found or does not implement IController.
我是否至少朝着正确的方向前进?