Asp.net mvc 5 缺少MVC 5 ViewComponent命名空间引用

Asp.net mvc 5 缺少MVC 5 ViewComponent命名空间引用,asp.net-mvc-5,asp.net-core-viewcomponent,Asp.net Mvc 5,Asp.net Core Viewcomponent,我正在使用MVC5并创建ViewComponent。面临命名空间缺少引用错误 找不到类型或命名空间名称“ViewComponent”(是否为“”) 缺少使用指令或程序集引用?) 下面是代码示例 public class SumViewComponent : ViewComponent { public IViewComponentResult Invoke(int a, int b) { return this.Content($"<span class=\

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

找不到类型或命名空间名称“ViewComponent”(是否为“”) 缺少使用指令或程序集引用?)

下面是代码示例

public class SumViewComponent : ViewComponent
{
    public IViewComponentResult Invoke(int a, int b)
    {
        return this.Content($"<span class=\"result\">{a + b}</span>");
    }
}
公共类SumViewComponent:ViewComponent
{
公共IViewComponentResult调用(int a、int b)
{
返回此.Content($“{a+b}”);
}
}

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

mvc 5没有ViewComponents,它们是在mvc 6中引入的。看