ASP.NET View Components: Remove default path to view

Viewed 1685

I want to return a View with a specific path to the view like so, return View(~/Views/Home). The type to be returned is an IViewComponentResult.

However, when the site gets rendered, it tries to find the view under: Components/{controller-name}/~/Views/Home.

So I want to ask you guys, if you know a smart way to delete Components/{controller-name}/ from the path. My view component class is deriving from the ViewComponent class.

The problem regarding this is that right now, you have to have a "Components" folder with the name of the controller as a subfolder which contains a Default.cshtml file. I do not like to have all my components inside one folder. I hope you have a solution.

1 Answers
Related