缺少 MVC 5 ViewComponent 命名空间引用

MVC 5 ViewComponent namespace reference missing

我正在使用 mvc 5 并创建 ViewComponent。面临命名空间缺少引用错误。

The type or namespace name 'ViewComponent' could not be found (are you missing a using directive or an assembly reference?)

这里是代码示例

public class SumViewComponent : ViewComponent
{
    public IViewComponentResult Invoke(int a, int b)
    {
        return this.Content($"<span class=\"result\">{a + b}</span>");
    }
}

我如何解决命名空间问题,mvc 5 应用程序是否支持它。

MVC 5 没有 ViewComponents,它们是在 MVC 6 中引入的。参见 this article