Question: Render MVC 6 ViewComponent returns HTML 500 Error

Question

Render MVC 6 ViewComponent returns HTML 500 Error

Answers 1
Added at 2016-01-09 11:01
Tags
Question

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.

Answers to

Render MVC 6 ViewComponent returns HTML 500 Error

nr: #1 dodano: 2016-01-13 10:01

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

View /Views/Shared/Components/PriorityList/Default.cshtml
Source Show
◀ Wstecz