DotNetNuke Tips & Tricks

Thursday, October 16, 2008 by Ian Robinson

Creating DotNetNuke Modules using a Web Application Project (WAP)

Filed under: Module Development

When creating a DNN module, you have the option to choose from the web site project (WSP), or a web application project (WAP). I prefer the web application project approach, and I'll explain it for developers who are new to module development, or unfamiliar with the WAP approach for developing modules.

There are two major reasons why I feel WAP is generally better than WSP for DNN module development.

1. Conciseness - the project contains only your module's code, nothing more. Separating your module from the DNN web site itself in Visual Studio really helps with performance and maintainability.

2. Compiled - I like having the code compiled into an assembly. This makes it easier for me to build a module package and distribute. I like to use a NAnt script for each module that creates the packages for me. The WAP project style lends itself to this approach.

If you'd like to give it a try - here are the steps involved.

  1. Create a new WAP project, or alternatively, use a C# DNN Module WAP Template

    Template: ASP.NET Web Application
  2. Place the root of the project in the DesktopModules directory of your DNN development web site's file system (e.g. ..\DesktopModules\MyModule\)

    Location: C:\inetpub\wwwroot\DotNetNuke\Website\DesktopModules
  3. Set the project to build the assembly and place it in the "bin" directory of the DNN web site

    Output path: ..\..\Bin\
  4. Set the project to launch your DNN web site (e.g. http://localhost/DotNetNuke) when you F5/run.

    Start URL: http://localhost/dotnetnuke 
  5. In order for Visual Studio to know about your development web site, make sure to set your project to use your IIS server, and set the Override application root URL to the root of your web site.  When you do this, Visual Studio knows that paths starting with "~" are really pointing to the DNN web site, and not just to your project.  This makes it possible to include controls from within the DNN site, like the DNN Label or URL control.

    Project Url: http://localhost/DotNetNuke/desktopmodules/MyModule,  Override application root URL: http://localhost/DotNetNuke

After your module is set up, you can import it (by importing the .dnn manifest file) into your development site, and run any database scripts that the module may have. Your module is now fully integrated into your DNN site.

TIP: to debug the module, you may find it helpful to "attach to process" in Visual Studio while you already have the web site running in a browser. This saves you from having to launch the web site multiple times.

Comments

jabbar
Thursday, September 3, 2009 5:03 AM
Hi,

1) with this is it possible to instal a module WITH SOURCE and that the source files are in the appropriate directory under DESKTOPMODULES folder.
2) does the module code still need to be distributed across app_Code folder
3) is installing a WAP module with source done in the same way as installing a module PA?

thnx
Ian Robinson
Thursday, September 3, 2009 3:01 PM
Hey jabbar,

1) yes. but those sources files will not actually be used for anything. (see below)

2) not with the web application project. It does not *use* the source code files. All of the files are compiled into an assembly (.dll) and that assembly is placed in the website's bin directory. The assembly is used *instead of* using the actual *.vb or *.cs files.

3) yes.

Take care,

Ian
blog comments powered by Disqus