Keld Jakobsen
Keld Jakobsen

Reputation: 193

Rendering ViewComponent returns HTML 500 Error

I have a very simple solution based on MVC 6.

ViewComponent -> /ViewComponents/PriorityListViewComponent.cs

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

"Partial" View /Views/Components/PriorityList/Default.cshtml

Empty view 

View /Views/Shared/Index.cshtml

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

The above returns an HTTP 500 error, and i can't figure out why. I think all rules regarding paths are being helt.

Upvotes: 1

Views: 711

Answers (1)

Keld Jakobsen
Keld Jakobsen

Reputation: 193

Figured out that error was due to wrong mapping of Views the correct directory should have been

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

Upvotes: 3

Related Questions