I'm currently looking at setting up the Examine search within Umbraco to provide a site search for content. I've followed the quick start guide here and everything works fine until I use a layout for the search page template.
When I submit the search form using a layout I receive the following exception:
Has anyone else come across this, and if so, would you be able to give me a nudge in the right direction please?
The issue was arising due to the document types using a composition for the page metadata. Within the layout, there was a partial view to render these metatags, which is why the model binder was trying to bind to IMetadata.
In the end I scrapped the view model and extended the model builder class for the search document type with the properties from the view model. That way it was always implementing IMetadata.
Search view model exception
Hi,
I'm currently looking at setting up the Examine search within Umbraco to provide a site search for content. I've followed the quick start guide here and everything works fine until I use a layout for the search page template.
When I submit the search form using a layout I receive the following exception:
Has anyone else come across this, and if so, would you be able to give me a nudge in the right direction please?
Thanks, Leon
Hi Leon!
I believe you need to change your
@inherits
at the top of your view. So it's the type ofSearchViewModel
instead ofIMetaData
. Something like this:Hope this helps!
//Johannes
Hi Johannes,
Thanks for the response.
Unfortunately it has already been changed. In the view I have:
The layout just inherits from:
Thanks, Leon
Just wanted to post an update.
The issue was arising due to the document types using a composition for the page metadata. Within the layout, there was a partial view to render these metatags, which is why the model binder was trying to bind to IMetadata.
In the end I scrapped the view model and extended the model builder class for the search document type with the properties from the view model. That way it was always implementing IMetadata.
Hi Leon
I'm facing the exact same problem.
Can you show how you managed to solved it :)?
is working on a reply...