I am using mvc 5 and creating ViewComponent. Facing namespace missing reference error.
The type or namespace name 'ViewComponent' could not be found (are you missing a using directive or an assembly reference?)
here is code sample
public class SumViewComponent : ViewComponent
{
public IViewComponentResult Invoke(int a, int b)
{
return this.Content($"<span class=\"result\">{a + b}</span>");
}
}
How can i resolve namespace issue, is it supported in mvc 5 application.
MVC 5 does not have ViewComponents, they were introduced with MVC 6. See this article