Composite C1 support ASP.NET MVC 3 and Razor
18 January 2011
Extending Composite C1 with ASP.NET MVC3 Razor
We have added MVC 3 and Razor support to Composite C1 via the C1 Package ‘Composite.AspNet.MvcPlayer’. After installing MVC 3 and the package you can build functionality for your pages using MVC 3, including the sweet Razor syntax.
[ Error ]Here are the steps required to start using all the MVC 3 goodies:
- Install MVC 3 - http://www.asp.net/mvc/mvc3
- Get a Composite C1 site up and running – download Composite C1 if you don’t have it yet.
- Create a site using the easy wizard – choose the demo site to get to the Razor fun fast.
- In the C1 Console go to System | Packages | Available Packages and install the "Composite.AspNet.MvcPlayer " package
- Create (or edit) a page, add the C1 Function "Composite.AspNet.MvcPlayer" – specify "/Home" as path. Publish the page.
- Go create a HomeController.cs file in the /App_Code folder and paste in the code below. Note the use of App_code is atypical – your controllers should live in assemblies or App_Code.
- Go create a "Home" folder below "Views" (ie. ~/Views/Home) and add a Index.cshtml file to it and paste in the code below.
- Save all, browse the page and see MVC 3 and Razor run.
You can dive deeper into MVC3 and Razor at http://www.asp.net/mvc/mvc3 or read our detailed "Hello World MVC 3" guide - enjoy!
Sample HomeController.cs
[ Error ]Sample Home/Index.cshtml view
Presentation no longer availablecomments powered by Disqus