【问题标题】:Rendering ViewComponent returns HTML 500 Error渲染 ViewComponent 返回 HTML 500 错误
【发布时间】:2016-01-09 10:22:55
【问题描述】:

我有一个基于 MVC 6 的非常简单的解决方案。

ViewComponent -> /ViewComponents/PriorityListViewComponent.cs

public class PriorityListViewComponent : ViewComponent
{
    public IViewComponentResult Invoke(int maxPriority)
    {
        return View();
    }
} 

“部分”视图/Views/Components/PriorityList/Default.cshtml

Empty view 

查看/Views/Shared/Index.cshtml

@{
    Layout = "~/Views/Shared/BaseView.cshtml";
 }
 @Component.Invoke("PriorityList", 1)

上面返回一个 HTTP 500 错误,我不知道为什么。我认为所有关于路径的规则都得到了遵守。

【问题讨论】:

    标签: c# asp.net-core asp.net-core-viewcomponent


    【解决方案1】:

    发现错误是由于视图映射错误导致正确的目录应该是

    View /Views/Shared/Components/PriorityList/Default.cshtml
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-29
      • 1970-01-01
      相关资源
      最近更新 更多