Click here to Skip to main content
15,867,141 members
Articles / Web Development / ASP.NET
Tip/Trick

Create Your First MVC Project in Umbraco (ver 6)

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
15 Jun 2013CPOL2 min read 34.6K   6   3
How to create your first MVC project in Umbraco

Introduction

Here, I am going to create a new blank MVC4 project in Microsoft Visual Studio 2010 and then I will add Umbraco 6.0.3 package to it. In this process, unfortunately, you may encounter a couple of bugs which have been highlighted in yellow.

Background

Umbraco is an open source ASP.NET CMS. More information regarding it can be found here.

Using the Code

  • Create an empty MVC 4 project in Visual Studio.
  • Add the NuGet Umbraco Cms Core Binaries package to manage various dependencies and references that Umbraco 6 requires. To do this, open Package Manager Console (From the Tools menu, select Library Package Manager and then click Package Manager Console) and type Install-Package UmbracoCms.Core -Version 6.0.3.

    Image 1

    Image 2

  • Download and copy all the files from the Umbraco installation ZIP archive directly into your project in Visual Studio except the App_Code and Bin folders – you won’t need the binaries as they are managed by NuGet and the App_Code folder is not used in a web application project.
  • Change the default mode for Umbraco from web forms to MVC in the defaultRenderingEngine setting in the Umbraco configuration file UmbracoSettings.config as shown below:
<templates>
	
<useAspNetMasterPages>true</useAspNetMasterPages>
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
	
</templates>  

Unfortunately, if you run the application now, you may encounter the error ApplicationException: The current httpContext can only be set once during a request.

The solution is to do the following in the web.config file.

Copy the httpModules tag and keep it handy for later use.

Add <add name="umbracoRequestModule" type="umbraco.presentation.requestModule" />
Add <add name="umbracoBaseRequestModule" type="umbraco.presentation.umbracobase.requestModule" />
Comment out <!--<add name=" UmbracoModule" type="Umbraco.Web.UmbracoModule,umbraco" />--> 
XML
<httpModules>
<!-- URL REWRTIER -->
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, 
UrlRewritingNet.UrlRewriter" />
<add name="umbracoRequestModule" type="umbraco.presentation.requestModule" />
<!-- UMBRACO --> 
<!--<add name=" UmbracoModule" type="Umbraco.Web.UmbracoModule,umbraco" />-->
<add name="umbracoBaseRequestModule" type="umbraco.presentation.umbracobase.requestModule" />
<!-- ASPNETAJAX -->
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, 
System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<!-- CLIENT DEPENDENCY -->
<add name="ClientDependencyModule" type="ClientDependency.Core.Module.ClientDependencyModule, 
ClientDependency.Core" />
</httpModules> 

Now the application will debug successfully and the Umbraco installation wizard will start to configure Admin and DataBase details.

The five steps of the wizard are displayed below:

Image 3

Image 4

Image 5

Image 6

Image 7

Image 8

Image 9

Image 10

Image 11

Points of Interest

The following articles were consulted to compose this blog. For more details of any particular domain, click on the appropriate link below:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionIs it free Pin
sachinthamke21-Jan-14 5:09
sachinthamke21-Jan-14 5:09 
AnswerRe: Is it free Pin
piyush_singh21-Jan-14 20:10
piyush_singh21-Jan-14 20:10 
GeneralFirst time worked on Umbraco CMS Pin
crazie.coder2-Jul-13 0:57
professionalcrazie.coder2-Jul-13 0:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.