Error loading Partial View (file: ~/Views/MacroPartials/MyView.cshtml). Exception: System.InvalidOperationException: The model item passed into the dictionary is of type 'Umbraco.Web.Models.PartialViewMacroModel', but this dictionary requires a model item of type 'SomeWebProject.Models.MyModel'. at System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) at System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) at System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult) at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, INode currentPage) at umbraco.macro.LoadPartialViewMacro(MacroModel macro) at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
You should only use a Partial View Macro for macros you want to be able to embed in the rich text editor, via the Embed Macro function. Try creating it as a Partial View, if you only need to reference it in a template. Then your inherit statement should work.
Partial View Macro with custom model
Hi all.
I had used this instruction for creating solution with umbraco 6.0.3: http://www.ben-morris.com/using-umbraco-6-to-create-an-asp-net-mvc-4-web-applicatio
Then I have created Partial View Macro File (named MyView) using appropriate node in "Developer" menu in admin view.
Then I have add MyView.cshtml to solution.
If I understand correctly the view should contains @inherits Umbraco.Web.Macros.PartialViewMacroPage
So, Is it a way to have cutom Model for view?
I'm trying to do something like:
@inherits UmbracoViewPage<SomeWebProject.Models.MyModel>
@Model.SomeProprty
But in this case I have the error:
Error loading Partial View (file: ~/Views/MacroPartials/MyView.cshtml). Exception: System.InvalidOperationException: The model item passed into the dictionary is of type 'Umbraco.Web.Models.PartialViewMacroModel', but this dictionary requires a model item of type 'SomeWebProject.Models.MyModel'.
at System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value)
at System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary)
at System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult)
at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, INode currentPage)
at umbraco.macro.LoadPartialViewMacro(MacroModel macro)
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
Thanks for any help
Hi Artem
You should only use a Partial View Macro for macros you want to be able to embed in the rich text editor, via the Embed Macro function. Try creating it as a Partial View, if you only need to reference it in a template. Then your inherit statement should work.
Check this topic too:
http://our.umbraco.org/forum/developers/api-questions/40032-MVC-Using-the-UmbracoHelper-dictionary-in-a-Partial-View-with-a-custom-model
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.