Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have my main site which has a macro which dynamically created my site nav. I wanted to use this within Articulate as well but having some problems getting it to work.
My macro sites in ~/Views/MacroPartials/siteNav.cshtml but if I try to load the partial with
@HTML.Partial("~/Views/MacroPartials/siteNav.cshtml") - Visual Studio throws an error -
An exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll but was not handled in user code
Additional information: The model item passed into the dictionary is of type 'Articulate.Models.ListModel', but this dictionary requires a model item of type 'Umbraco.Web.Models.PartialViewMacroModel'.
How do I fix this? Thanks.
I am not great on macros, but my understanding is that you create a macro and then create the macro partial view so should you not be asking for the macro instead of its partial view ?
You are trying to render a Macro as a Partial View. These are 2 different things. A Partial View, is an MVC partial view. A Macro uses a Partial View but can have specific parameters passed to the view.
If you are just trying to render an MVC Partial View, you don't need to create a macro, you just use MVC Partial Views the way that they were designed. Macro's generally aren't necessary unless you are embedding them in a rich text editor, or your editors need to pass in specific macro parameters.
You are getting this exception because your view is expecting a model of PartialViewMacroModel ... which is used by partial view macros, but the model being used to render your page is ListModel (which is of type IPublishedContent).
You can read more about macros here: https://our.umbraco.org/Documentation/Getting-Started/Design/Templates/Macros/
Thanks! I just followed a tutorial which showed me to put the code in to a macro. I've moved it out and the code still works in the partial. Will look at pulling that over to the template but can't see why it won't work now.
Thanks for your help both! Another step closer to getting my site launched!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted