Some months ago we have migrated our Umbraco6-WebForms macros (user control) to Umbraco6-MVC macro (partial view/SurfaceController). I don't know if you have the same scenario, but I can share what we did and I hope this can help you.
Our solution is divided in multiple class library projects that contain both user controls or MVC controllers and one web project that orchestrates and composes the others (with DI , environment configuration, etc).
Thanks to the full compatibility between WebForms and MVC, we were able to do a "slow migration process" from WebForms to MVC, having a long period in which our application was using both type of Macros (WebForms and MVC) in the same time.
These are the steps followed to migrate a project and to create MVC macros.
Update WebForm project to MVC
We followed the instructions described in this article. I.e.
- Install MVC 4 (required by Umbraco 6.x) in each project
- Open Package Manager Console
- run the following command (we use that particular MVC version because it is the same used by Umbraco 6.2.4):
Install-Package Microsoft.AspNet.MVC -Version 4.0.20710.0
- Install Microsoft ASP.NET Web Optimization Framework to allow the compilation of Razor scripts, using this command:
Install-Package Microsoft.AspNet.Web.Optimization -Version 1.1.3
(see this post)
- Unload the project to modify the .csproj file
Insert/add the following tag (under ProjectGuid) to enable MVC scaffolding
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
reload the project
- add these reference to the project if missing: Umbraco, Microsoft.CSharp (it enable the use of dynamic type like ViewBag), ClientDependency.Core.Mvc
Create specific MVC Areas
This step allows us to separate the old webForms parts from the new MVC ones in the same project. Furthermore the VisualStudio scaffolder creates a lot of stuff for you (folders, web.config and much more). To do that, at the project level, Add new Area (you should have this option in the contextual menu after the steps above)
Now you should be able to have new MVC code togheter with webforms.
Create your MVC Umbraco Template
Umbraco allows you to define your default rendering engine. In mixed project you should have MVC
in the configuration file. See this post for more info.
Now you can create your new template in Umbraco back-office.
It should be a beginning.