{"id":849,"date":"2014-04-30T01:47:46","date_gmt":"2014-04-29T20:17:46","guid":{"rendered":"http:\/\/www.harshbaid.in\/?p=849"},"modified":"2014-04-30T02:02:17","modified_gmt":"2014-04-29T20:32:17","slug":"umbraco-cms-asp-net-mvc-part-3-inside-visual-studio","status":"publish","type":"post","link":"https:\/\/www.harshbaid.in\/2014\/04\/30\/umbraco-cms-asp-net-mvc-part-3-inside-visual-studio\/","title":{"rendered":"Umbraco CMS with ASP.NET MVC – Part 3 Inside Visual Studio"},"content":{"rendered":"

In this post for Umbraco CMS we will learn regarding creating Visual Studio Solution. Main motive behind creating VS\u00a0Solution is to\u00a0work in proper\u00a0structured manner and when work in team it is helpful so that Team can Commit\u00a0their file\u00a0changes under Source Control when developing with Umbraco CMS.<\/p>\n

In the Introduction<\/a> post\u00a0you can read the\u00a0brief roadmap about\u00a0posts on Umbraco CMS and MVC development. Part 2<\/a> of this series describes about Umbraco installation and IIS<\/a> configurations.<\/p>\n

For this post I have used Visual Studio 2013 but 2012<\/a>\u00a0version will also do. This version of Umbraco is using .NET Framework 4.5<\/a><\/p>\n

Step 1 – Create Blank Solution for UMBRACO CMS<\/h2>\n

Start Visual Studio and use the shortcut for create new\u00a0project i.e. Ctrl<\/kbd>+Shift<\/kbd>+N<\/kbd><\/p>\n

Create a Blank Visual Studio Solution.<\/p>\n

In Visual Studio 2013, Navigate to ‘Visual C#<\/a>‘ > ‘Web’ > Select ‘ASP.NET Web Application<\/a>‘ as can be seen in the screen below.<\/p>\n

\"Create<\/a><\/p>\n

Note: If you are using Visual Studio 2012 or else the step to create Blank Solution may be different. For example in Visual Studio 2012 you can navigate to\u00a0‘Visual C#’ > ‘Web’ > Select ‘ASP.NET MVC 5 Empty\u00a0Project’.<\/p>\n

Considering\u00a0you have followed the Part 2<\/a>\u00a0regarding Umbraco Installation and Site root folder; keep the backup of the Umbraco site root folder specifically web.config, Global.asax and ‘Views’ folder.<\/p>\n

Then uncheck the option for “Create directory for solution”<\/p>\n

Set the\u00a0Location\u00a0to the\u00a0Umbraco site root folder.<\/p>\n

Set the Solution name. Here we have created Solution with name “UmbracoMvc” and then click “OK”<\/p>\n

Next in the “New ASP.NET Project” dialog,\u00a0Select template\u00a0“Empty” and tick\u00a0the “MVC” check box option<\/p>\n

\"Select<\/a><\/p>\n

Then click “OK”.<\/p>\n

Step 2 – Verify the Solution Structure and Physical Files<\/h2>\n

After this you can verify the folder structure is created as below screen. Here “Umbraco” is the Solution\u00a0Folder\u00a0and “UmbracoMvc” is the Project\u00a0Folder.<\/p>\n

\"Blank<\/a><\/p>\n

After we create blank solution, Visual Studio replaces the existing Umbraco web.config and other imp. files due to this behaviour of VS;\u00a0we need to restore the files and folders (shown in below screen) from the original version that we have in backup, that we took in previous step, to\u00a0“UmbracoMvc” project folder.<\/p>\n

\"Copy<\/a><\/p>\n

Now we have successfully created blank solution and recovered the files needed. So we need to verify that the Umbraco site is still working at URL ‘http:\/\/UmbracoMvc\/’.<\/p>\n

STEP 3 – Include NECESSARY files in the Solution<\/h2>\n

Open\u00a0Visual Studio’s Solution Explorer and select option “Show All Files” highlighted in screen below.<\/p>\n

\"Select<\/a><\/p>\n

Next include the files and folder as required but\u00a0do not include the folders named “Umbraco” and “Umbraco_Client” because those part we will not work. I have shown in below screen what I have\u00a0included in my solution.<\/p>\n

\"Files<\/a><\/p>\n

STEp 4 – Umbraco MVC Configurations<\/h2>\n

In Umbraco MVC,\u00a0we generally not define routes. For this reason we will clean up the routes definition from “RouteConfig.cs” as shown in screen below.<\/p>\n

\"Remove<\/a><\/h2>\n

Next we will configure the Umbraco site for default rendering to MVC as shown in the screen below.<\/p>\n

Open the “umbracoSettings.config” from “Config” folder and\u00a0change the template’s default Rendering to “Mvc”.<\/p>\n

\"Default<\/a><\/p>\n

Note: This will affect the creation of new Templates from Umbraco Client\/Administration region. Also in new version of Umbraco default rendering is ‘Mvc’, so you can skip this part for Umbraco version\u00a07.1.1<\/p>\n

Conclusion<\/h2>\n

So we have completed the exercise to Create Visual Studio Solution for Umbraco Web development and we also did configurations for ASP.NET MVC 5 version. After this much you can add the source files and folders to any Source Control\u00a0that works for you. Your Team will love to work in Umbraco CMS after these efforts.<\/p>\n

In the next\u00a0post\u00a0we will see the how Umbraco CMS works with\u00a0MVC or in other words how to cook the ASP.NET MVC recipe in Umbraco and also migration\u00a0points for converting existing ASP.NET MVC sites to Umbraco MVC.<\/p>\n

 <\/p>\n

Keep sharing your ideas and\u00a0suggestions in the comments.<\/p>\n

Liked this post? Then\u00a0spread this post to your friends.<\/p>\n

 <\/p>\n