DotNetNuke 7

A few days ago I installed DotNetNuke (DNN) 7.0.0 to mainly test the new version of it’s Services Framework that is based on the Web API stack.

Installation

You can download the DotNetNuke 7 Community Edition installation archive here.

Unblock the archive and extract it to a new directory under your IIS inetpub folder. For example, c:\inetpub\dnn7.

icacls c:\inetpub\dnn7 /t /Grant NetworkService:F

OPEN Internet Information Services Manager and create a new IIS application that is rooted at the DNN path. Here is an example of the applications advanced settings.

DNN 7 IIS application advanced settings

The DNN 7 application pool runs under .NET 4.0 and uses the Network Service profile. Under the application pool advanced settings, change Process Model > Identity to NetworkService

DNN 7 IIS application pool advanced settings

Map the application hostname to the localhost IP address. OPEN notepad (run as administrator), modify your hosts file in C:\Windows\System32\Drivers\etc. For example, add this line for an application with a host named dnn7:

127.0.0.1       dnn7

Create a blank SQL Server database. For example, using SQL SERVER Express 2012, I logged in using the sa account and created a new database named DNN_7. NOTE: When the SQL Server is installed using only Windows Authentication, the sa login is disabled. To enable the sa account, see Change Server Authentication Mode.

To complete the installation, restart the application in IIS and load the host you specified in the hosts file in a web browser. For example, http://dnn7

After completing the install, the new DNN 7 loaded quickly and looked nice. First thing I tried to do was create a page and add a module to it. While logged in as host, when I click on the new “Edit This Page” button, the page refreshes and I’m still in View mode. After contacting DNN support, I was instructed to change the control panel to RIBBONBAR, the old control bar from DNN 6:

Host > Host Settings > Other Settings, change the Control Panel from CONTROLBAR to RIBBONBAR

After the change, I was able to toggle the page into Edit mode. According to DNN support, this issue was actually reported during the Beta, thought to be fixed, then popped up again during the release. Their developers are hard at work trying to resolve it for DNN 7.0.1. Unlike my experience, you may not have any issues at all with the new DNN 7 CONTROLBAR control panel. The developers have narrowed it down to something in IIS, however they are not sure exactly which configuration. My configuration that has this problem is IIS Version 7.5.7600.16385 on Windows 7 Professional. The new DNN 7 CONTROLBAR control panel worked as expected in DotNetNuke 7 on Windows 8 Professional, IIS Version 8.0.9200.16384

Services Framework

Read these two DNN blog post:* Getting Started with Services Framework WebAPI Edition

Clone the master branch of this GitHub repository that Scott Schlieser had built for a session at 2012 Charlotte Day of DotNetNuke. At the time of this post, the master branch contained the revised DNN 7.0 Web API based implementation.

DNN Services Framework ExploreSettings Module

Creating your own DNN WebServices class library

In Visual Studio, create a new C# .NET Framework 4 Class Library Project
dnn-web-services-proj-create

This library project does not need to be included within the DesktopModules folder or for that matter the DNN website. However, it’s build needs to be in the DNN root bin. I prefer to locate the class library in the DesktopModules folder keeping all my source and module code together. Next, right click on the newly created WebServices project, select Properties and set the build output path to the DNN root bin for all configurations as shown in this image.

dnn-web-services-build-output

In the Solution Explorer, right click on the References node and select Add Reference to open the Reference Manager.

dnn-web-services-add-reference

Browse to the root bin folder which in this example is C:\inetpub\dnn7\bin to select and add the following dll’s:

  • DotNetNuke
  • DotNetNuke.Web
  • System.Net.Http
  • System.Net.Http.Formatting
  • System.Web.Http

Next, under Assemblies > Framework, select and add this dll

  • System.Web

Your References should now look something like this in Solution Explorer

dnn-web-services-references

Next, create a class to Register Routes. the project template created a Class named Class1. Let’s rename Class1.cs to RouteMapper.cs and allow Visual Studio to also rename the class when prompted. At the very top of the class, replace all the usings with just these two:

  • using System;
  • using DotNetNuke.Web.Api;

The RouteMapper class also needs to inherit the IServiceRouteMapper interface. After adding that your empty RouteMapper class should look like this:

using System;
using DotNetNuke.Web.Api;

namespace WebServices
{
    public class RouteMapper : IServiceRouteMapper
    {
    }
}

Now add the RegisterRoutes method to our RouteMapper class as follows to map a route for the controller we will create next.

using System;
using DotNetNuke.Web.Api;

namespace WebServices
{
    public class RouteMapper : IServiceRouteMapper
    {
        public void RegisterRoutes(IMapRoute mapRouteManager)
        {
            mapRouteManager.MapHttpRoute("Services", "default", "{controller}", new[] { "WebServices" });
        }
    }
}

Add a new public class named TestController.cs that inherits the DnnApiController class and contains a Get action as follows:

using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;

namespace WebServices
{
    public class TestController : DnnApiController
    {
        [AllowAnonymous]
        public HttpResponseMessage Get()
        {
            return Request.CreateResponse(HttpStatusCode.OK, "Hello From DotNetNuke!");
        }
    }
}

Now build the project and verify that there is a WebServices.dll in the DotNetNuke root bin. Test the service by loading the endpoint url in a browser like http://dnn7/DesktopModules/Services/API/Test

Other Resources

comments powered by Disqus