68

I've followed the steps from http://memoryleak.me.uk/2009/04/umbraco-and-aspnet-mvc.html and integrated MVC in Umbraco with success, but I still have a problem which is critical for me.

Is there any way to inherit the Umbraco defined templates in an MVC view? As I understand the problem is that the Umbraco templates become HTML only at runtime and the doctype properties, as @nodeName, are not recognized and "Object null reference" exception being thrown because of this.

Lucian Podereu
  • 798
  • 7
  • 10
  • curious how you've got on, did you get this working – frosty Jan 14 '10 at 13:29
  • another one who is curious - did you get this sorted? – flesh Jan 16 '10 at 15:20
  • 7
    I think the next version of Umbraco will be using ASP.Net MVC http://our.umbraco.org/wiki/user-groups/australia-and-new-zealand/joint-sessions/what-you-missed-from-codegarden-09---minutes – Aim Kai Feb 19 '10 at 14:39
  • I didn't found a solution, I simply renounced MVC. – Lucian Podereu May 20 '10 at 14:05
  • 6
    They say the next Umbraco will be MVC based. I'd wait for that. – turtlepick Dec 30 '10 at 03:51
  • IF you are still studying Umbraco, you can try also KooBoo. KooBoo is a Asp.Net MVC based CMS. It has a lot of features, a good multisite support, and is since your creation MVC based. – Adilson de Almeida Jr Mar 07 '11 at 03:35
  • as far as i know mvc umbraco is still quite some way off – Paul Carroll Mar 21 '11 at 05:49
  • In case you haven't already checked this link out? http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx – James Kyburz Apr 02 '11 at 08:56
  • N2CMS already has MVC integration: http://www.n2cms.com , and has done for quite a while. But it requires C# knowledge rather than XSL knowledge – Chris S Apr 08 '11 at 23:24
  • Just a quick note to let anyone reading this know that the development of the mvc version of Umbraco (v5) has ended: http://umbraco.com/follow-us/blog-archive/2012/6/13/v5-rip.aspx It seems however that the Umbraco team intend to integrate features from v5 into the v4 product. – WooWaaBob Jun 15 '12 at 12:05
  • 1
    Adding my little comment here one year later: Umbraco 4.10+ and especially Umbraco 6+ now support MVC. – Funka Jun 13 '13 at 00:00
  • Actually I am not sure what your question is? If you are trying to get Umbraco content in to another MVC site then the best way to go is expose it via UmbracoAPI. Umbraco has a bunch of Services that make light work of this. best of luck – Darren Street Jul 28 '17 at 10:58

4 Answers4

10

This question is really old and not relevant to the current versions of Umbraco.

Just in case anybody is still not aware - All versions of Umbraco since 2013 (6, 7 and now 8) support MVC

wingyip
  • 3,465
  • 2
  • 34
  • 52
5

Having had a look at the blog post it seems that this is not actually integrated with Umbraco but working alongside Umbraco.

In that it is effectively its own HttpHandler. This means it is bypassing the Umbraco Httphandler and a whole bunch of Umbraco functionality relating to templates and the CMS itself.

Getting MVC to utilise Umbraco templates is (probably) not possible without modifications to the core application (in version 4+). However that doesn't mean you can't use MVC alongside Umbraco with Umbraco acting as a content repository for a MVC application.

You could easily create MVC controllers which pulled data from Umbraco and made that available to your views. For example you could use Umbraco Linq2Umbraco for this.

If you give more details as to the precise errors you are getting and exactly what you are trying to achieve, it may be the solution is in how you structure your application rather than attempting to brute force Umbraco 4+ to do something that will be native in Umbraco 5 (which is scheduled for release some time this year). The source code for 5 is on Codeplex and may be a good place to have a look and see how the Umbraco core team are approaching this.

There is an old discussion about this here: http://forum.umbraco.org/yaf_postst5106_Using-ASPNET-MVC-with-Umbraco.aspx

and more recently here: http://our.umbraco.org/forum/getting-started/installing-umbraco/2668-Use-Umbraco-with-aspnet-MVC

Further discussion can be found here: http://our.umbraco.org/forum/developers/extending-umbraco/17523-Umbraco-461-and-MVC-3

and even more here: http://our.umbraco.org/forum/developers/extending-umbraco/6837-Umbraco-Website-And-MVC-Website-In-ONE

Tim
  • 4,414
  • 4
  • 35
  • 49
2

Rather than trying to use the Umbraco controls, you might consider writing some HtmlHelper extension methods that use the umbraco.NodeFactory.Node class to obtain the content you're trying to display in your views. Writing methods that mimic (or simplify based on your needs) umbraco.presentation.templateControls.Item and umbraco.presentation.templateControls.Macro may be enough for you.

EDIT

I went down this path with some success. I also took a look at the MVC source to find out how partial views were being added to the underlying web forms controls collection. I ended up writing a class that inherits from the umbraco.presentation.templateControls.Macro class that looks a lot like the System.Web.Mvc.ViewUserControl class.

Aaron
  • 2,427
  • 4
  • 30
  • 41
0

Umbraco is moving to donet core now https://umbraco.com/blog/net-core-alpha-release/

Kamalakar
  • 389
  • 2
  • 9
  • Links to external resources are encouraged, but please [add context around the link](https://meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. [Answers that are little more than a link may be deleted](https://stackoverflow.com/help/deleted-answers) – Sabito stands with Ukraine Jan 22 '21 at 07:41