Thoughts from the Wet Coast

The musings of an ASP.NET Developer from Canada's We(s)t Coast

DNN Loves MVC: 1 - Introduction

Category: ASP.NET DotNetNuke
Last Modified: May 2 2017
Mar 28 2015

DNN_Loves_MVC_LogoLast summer DNN Corp announced their intention to support MVC in future versions of the eponymous DNN Platform. 

Last week Joe Brinkman announced that the initial fruits of those labours was now available in a CTP of DNN 7.5.  The support introduced in 7.5 will allow developers to build their DNN modules using ASP.NET MVC version 5.1.1 or later. 

In this blog series I will show how we expect module developers to use this new support.  I will be developing a simple Family Tree module which will use some libraries that I have already built – I will provide the relevant details when necessary.

A bit about routing

The first thing to note is that the approach we have taken is to embed the MVC application inside an ASP.NET Web Forms server control.  This is a similar approach to how we provided Razor support a few years ago, and we intend to use the same approach to support Single Page Application style modules using HTML 5, JavaScript and CSS. 

This doesn’t really affect how module developers code their MVC modules, except that it means that routing is done a little differently.  As a module developer you don’t need to define any routes as DNN handles the routing (or URL Rewriting).  We will however still support Html and Url helpers that defined links using action names and controller names.  However, we will create urls that work within the DNN Url handling system.

Setting up your environment

In this introductory blog I will show how to set up Visual Studio (2015) to develop our first DNN MVC module.  As a pre-requisite you will need to install the CTP which you can get from codeplex ( Alternatively you can get the latest code by cloning the feature/7.5.0 branch of the DNN.Platform Github repository (

Open Visual Studio (in my case I am using Visual Studio 2015 CTP 6) and create a solution for you MVC module.  Once you have created your solution, add a Web Application Project – select the Empty template (1) but check MVC (2) so that the MVC references are added to the empty project.

Figure 1 - Creating an MVC project


Remove the files and folders added by the template – except the Controllers, Models and Views folders – and add an App_LocalResources folder (for our localization resources).  You should have something that looks like Figure 2.

Figure 2 – Empty MVC Project


The first thing we will do is to add an MS Build file so we can build and deploy our modules.  This MS Build file is shown in Figure 3 (don’t worry if you can’t read everything in the file – the source for this project is available on Github (, so you can copy the file on Github for use in your project.

Figure 3 – The File


There are two important properties in this file which will need to be modified for your installation:

  1. The WebsitePath must point to the root of your DNN 7.5 website
  2. The ModuleFolderName points to where your module will be deployed within the website – your module should be under the MVC folder within DesktopModules.  This is important as this will mean that the web.config file that lives in that folder will apply to your MVC module.  This web.config files allows the Razor Views to work just as they would in a stand-alone MVC Application with the change that the base WebViewPage is a DnnWebViewPage.

To enable the build file to work you need to modify the module’s project file.  To do that, “Unload” the project and Edit the project as an XML file, and insert the Import element highlighted in Figure 4 at the bottom of the file.

Figure 4 – Adding the Import Statement to the Project File


Now we should be ready to start building our first MVC View, which I will do in the next blog post.

For more information


The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.