ChrisHammond / DNNTemplates

Christoc's DotNetNuke Extension Development templates for Visual Studio
http://www.christoc.com/Products/DNN-Development-Templates
Other
97 stars 38 forks source link

Multiple MVC Modules on the same page #36

Closed ChrisHammond closed 7 years ago

ChrisHammond commented 7 years ago

If you have multiple MVC modules on a page you get an error similar to

[L]Error: TestMVC1026 is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: The model item passed into the dictionary is of type 'System.Collections.Generic.List1[Christoc.Modules.TestMVC1026.Models.Item]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[Christoc.Modules.TestMVCApril.Models.Item]'. ---> System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Collections.Generic.List1[Christoc.Modules.TestMVC1026.Models.Item]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[Christoc.Modules.TestMVCApril.Models.Item]'. at System.Web.Mvc.ViewDataDictionary1.SetModel(Object value) at System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) at System.Web.Mvc.WebViewPage1.SetViewData(ViewDataDictionary viewData) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at DotNetNuke.Web.Mvc.Framework.ActionResults.DnnViewResult.ExecuteResult(ControllerContext context, TextWriter writer) at DotNetNuke.Web.Mvc.Framework.Modules.ModuleExecutionEngine.ExecuteModuleResult(ModuleRequestResult moduleResult, TextWriter writer) at DotNetNuke.Web.Mvc.MvcHostControl.RenderModule(ModuleRequestResult moduleResult) at DotNetNuke.Web.Mvc.MvcHostControl.OnLoad(EventArgs e) --- End of inner exception stack trace ---

naineshmehta commented 7 years ago

@ChrisHammond, I have this same issue, did you work out how to get around it?

ChrisHammond commented 7 years ago

@naineshmehta I haven't come up with a workaround yet

naineshmehta commented 7 years ago

@ChrisHammond well here is something, I upgraded my code to DNN 9 and it all seems to work fine now!

ChrisHammond commented 7 years ago

cool @naineshmehta I was thinking it likely wasn't a Module issue but a framework issue, that makes me believe that might actually be the case :D

swalker1595 commented 6 years ago

I had this issue this morning with DNN9. It was unrelated to what page the modules were on, but had to do with an error on my part.

When creating my new module, I was attempting to rename everything from "Item" to "Event" in my Models, Controllers, Views, everywhere. If you miss any one of those places, you will get the error above.