Please help me get a basic MVC macro to work in V6
Hello,
I'm swotting up on MVC because I want to use it in my next site build. I quite new to MVC but have plent of experience with Umbrcao and ASP.Net.
I've been through the Music Store tutorial to get an idea of how it hangs together as well as looking at some MVC Umbrcao related doces.
I've waited until V6 because I wanted to start with a version that had complete support for MVC, which I understand it now has.
There's currently not much in the way of tutorials on how to get an MVC macro working specifically with V6 but I have just watched and implemented the MVC in Umbraco 4 video for my V6 site.
I'm trying to build and MVC macro that I can drop into a rich text editor but after following the video and making a few allowances for the different versions it is not working.
Thanks for the help Damien, I remember coming accross SurfaceController documentation here but I wasn't sure if it applied.
The MVC stuff in the recent releases has all been moving so quick it difficult to know what's applicable in the documentation.
I've tried calling the controller StatusSurfaceController and inheriting from Umbraco.Web.Mvc.SurfaceController but I still have the same problem at the moment.
I'm going to start from scratch and follow that tutorial you posted and see where that gets me in V6. :-) Will let you know.
Calling navigaton partial in a _layout.cshtml view, with @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
at the top of both, with the partial in the partial folder.
Have used pretty much the same on a couple of builds of 4.10+ and 6RC without an issue, it was just odd that this appeared, but for no reason at all strted working, but the error message remained in VS2012. Bear in mind this is a straight partial, not a macro partial.
It pointed me in the direction of creating your MVC macros via the developer section in the editor,'Partial View Macro Files'.
If you create your macros there they all start with:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
Now you can't have both the @inherits and @model lines as it complains. If you remove the @model in favour of the @inherits it will also fail.
The model item passed into the dictionary is of type 'MvcUmbracoTest.Models.MemberLoginModel', but this dictionary requires a model item of type 'Umbraco.Web.Models.PartialViewMacroModel'.
I'm afraid this is where my current understanding fails me.
Please help me get a basic MVC macro to work in V6
Hello,
I'm swotting up on MVC because I want to use it in my next site build.
I quite new to MVC but have plent of experience with Umbrcao and ASP.Net.
I've been through the Music Store tutorial to get an idea of how it hangs together as well as looking at some MVC Umbrcao related doces.
I've waited until V6 because I wanted to start with a version that had complete support for MVC, which I understand it now has.
There's currently not much in the way of tutorials on how to get an MVC macro working specifically with V6 but I have just watched and implemented the MVC in Umbraco 4 video for my V6 site.
I'm trying to build and MVC macro that I can drop into a rich text editor but after following the video and making a few allowances for the different versions it is not working.
I simply get an error when the page is loaded.
Error loading MacroEngine script (file: ~/Views/MacroPartials/Index.cshtml)
Some things I have not done because of the versions differences:
The model is very basic:
So is the Controller:
The view was auto generated:
What have I not done?
Thanks, Matt
The defaultRenderingEngine is set to Mvc.
Don't you need to call your controller StatusSurfaceController
The word surface needs to be in there if i remember rightly.
Also inherit from Umbraco.Web.Mvc.SurfaceController
Just had a quick look at a test i did a while back and thats how i did it... unless ts all changed!?? Not played with it for a bit.
Here this may help:
http://24days.in/umbraco/2012/creating-a-login-form-with-umbraco-mvc-surfacecontroller/
Thanks for the help Damien, I remember coming accross SurfaceController documentation here but I wasn't sure if it applied.
The MVC stuff in the recent releases has all been moving so quick it difficult to know what's applicable in the documentation.
I've tried calling the controller StatusSurfaceController and inheriting from Umbraco.Web.Mvc.SurfaceController but I still have the same problem at the moment.
I'm going to start from scratch and follow that tutorial you posted and see where that gets me in V6. :-)
Will let you know.
Cheers, Matt
What do you get in the debug output?
add the umbDebugShowTrace=true to the request and make sure debug is on - you might get a little more info to go on from that.
And check your view is inheriting the correct class:
Let me know if you dont get it working and i'll have a bash - need to get a v6 site spun up myself.
I did manage to write a custom controller in 4.10 because i wrote an image handler as a test - so i could look that up.
Heres that imagehandler - http://our.umbraco.org/projects/starter-kits/standard-website-mvc/bugs-issues/36039-How-about-add-WebImage-helper-example-code-to-this-package
Strangely ?umbDebugShowTrace=true is not working.
umbracoDebugMode is set to true in the web.config. A v6 bug maybe?
I followed the "Creating a Login form with Umbraco MVC SurfaceController" tutorial and it all worked fine.
I then moved the view to the MacroPartials folder so that I could create a macro out of it. That's when it goes wrong:
Error loading MacroEngine script (file: ~/Views/MacroPartials/MemberLogin.cshtml)
Interestingly the view continues to work from the template with
@Html.Action("MemberLogin","MemberLoginSurface")
even though I have moved it.
Is the security set ok on the Partials folder?
I cant get the trace either. I know logging has been moved into log files but would have thought trace would stay the same so maybe a bug?
Looks like i was right - trace now lumped into the log files.
Hi Matt and Damian
Don't know if it is related, but had an odd one -
Ah think i might know where you have gone wrong.
How and where are you calling the partial view?
Macros are slightly different beasts in mvc. Have a read of this post by Shannon - he covers this about half way down the post.
http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
Hi Damian
Thanks for reply.
Calling navigaton partial in a _layout.cshtml view, with @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
at the top of both, with the partial in the partial folder.
Have used pretty much the same on a couple of builds of 4.10+ and 6RC without an issue, it was just odd that this appeared, but for no reason at all strted working, but the error message remained in VS2012. Bear in mind this is a straight partial, not a macro partial.
Don't know if that makes it any clearer.
Regards Gary
Thanks for the link to that doc Gary.
I've downloaded it too.
I did find some documentation on creating a basic MVC macro but I think it's for v5.
It pointed me in the direction of creating your MVC macros via the developer section in the editor,'Partial View Macro Files'.
If you create your macros there they all start with:
Now you can't have both the @inherits and @model lines as it complains.
If you remove the @model in favour of the @inherits it will also fail.
The model item passed into the dictionary is of type 'MvcUmbracoTest.Models.MemberLoginModel', but this dictionary requires a model item of type 'Umbraco.Web.Models.PartialViewMacroModel'.
I'm afraid this is where my current understanding fails me.
Cheers, Matt
is working on a reply...