Search code examples
c#asp.net-mvcsitecoreplaceholderasp.net-mvc-viewmodel

sitecore mvc return view with viewmoldel


I'm working on a MVC website with Sitecore. In a specific Controller I return a (partial)view with a ViewModel, however the page is only showing the plain (partial)view which I returned. So there is no styling at all. This sounds about right but the issue for me is that I expected the full page with all other partial views who are configured via Sitecore on the presentation details.

I'm trying to avoid using ViewBags because the ViewModel is there and I think it is and looks better to use the ViewModel.

My code is very straightforward:

The Controller returns the view like below:

return PartialView("NameOfTheView", viewModel);

And in the page I'm just parsing the ViewModel items, nothing special there.

I'm using a placeholder in Sitecore. This is where the view should be shown. Could it be that the placeholder is issue here?

Hope my question is clear and someone knows the answer obviously ;-)


Solution

  • Thanks for all the help guys!

    After checking all you suggestions I found my answer in a 'related' question (Sitecore MVC form postback does not return a full layout) his question described exactly my problem only in less words and better description...

    In my case my mistake was using @Html.Sitecore().FormHandler("Controller", "Action") instead of @Html.Sitecore().FormHandler() which solved the problem.