The differents between (MC)V and Composite?

Topics: General, MVC
Aug 5, 2011 at 1:53 PM


At this moment i'm looking how to implemented MVC/Razor in combination with Composite. The MvcPlayer implemented I succesfully without problems. But the design is in VS then.

I'm asking repeatly by my self, what are the roles for an application by using Composite and MVC application. What I mean is: Composite is a "View" (with editor functions) and Razor (with the Visual Studio .cshtml files) is also the View of the application. 

What are the different between these? I think, I don't have to use the .cshtml files but I like razor (also my designers). And if I let the design/view in composite, how can I use the Controllers  files then? Or isn't possible?

I'm a newbie about Composite so it isn't clearly enough for me about this.



Aug 5, 2011 at 2:54 PM
Edited Aug 5, 2011 at 2:57 PM

First af all... MVC is not Razor, like Razor is not MVC... Razor is just a syntax and can be used in all kinds of different contexts, also in non-MVC with what Microsoft calls WebPages. So you need to be more specific if its razor you want, or mvc. Clearly, razor is a sideeffect of choosing MVC until C1 gets first-class-citizen support for it. Which is not that big of a deal really... see this discussion about razor support in C1

If its pure MVC, witch controller and views and actions for each and every page in the system, then you're a bit out of luck. There is this discussion about MVC a rendering engine in C1, but more planning is needed of how to map page types/templates into controller and how views and models should work

If you want to use razor for making the whole layout/template of the site, it should be possible with some tweaking of WebPages. Just like its possible to use Masterpages for templating, its possible to invoke a <template_name>.cshtml file for a given C1 page and use that for the rendering. instead of the XSLT template provided per default. You would still be able to insert normal XSLT functions as usual, like the functions editors insert into the page content also works as normal. Only note is, that content inserted into <head> of a xslt-function will be ignored since Razor doesn't have the notion of a control-tree like ASP.Net webforms does, so there is no way of referencing the head-sections and insert stuff into it.

If you want to write normal visual functions, but with razor instead of XSLT, then you should go with the MVC player approach. There is a bit of overhead dealing with controllers and views, but as a side-effect you get Razor syntax for free and can insert is as functions in your page content or layouts.