(this is a cross posted from the LightSwitch Help Website)
Integrating a LightSwitch application into DotNetNuke has been covered before in Deploy Your LightSwitch Application As A DotNetNuke Module. The problem with that solution is:
- It requires a lot of assemblies to be added to your DotNetNuke site
- It requires edits to your DotNetNuke site’s web.config file
- You can only deploy one LightSwitch application to a DotNetNuke site
The third one is usually a show-stopper. This method, using IFrames, gets around all those problems.
The Application
We start with the application used in It Is Easy To Display Counts And Percentages In LightSwitch.
In that application, we wire-up a method on the PhoneCall table and add the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
public partial class PhoneCall
{
partial void PhoneCall_Created()
{
MessageTakenBy = this.Application.User.Name;
}
}
}
That is all that is required to integrate the application into DotNetNuke. When a user is logged-in, DotNetNuke will pass the authenticated User Name to the LightSwitch application, so it can save the user that creates the Phone Call record.
We go into Properties and turn on Forms Authentication.
We also set the application to be a Web Application that is deployed on IIS.
In the Visual Studio Configuration Manager, we switch to Release.
We then Publish the application.
When we get to the database screen, we specify the DotNetNuke database.
Calling The LightSwitch Application From DotNetNuke
We follow the directions in this post by LightSwitch team member Valerie Andersen:
http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/60c76dde-07dd-48f7-8aed-f7aec66c47d4
Essentially we need to:
- Copy the Machine Key from the DotNetNuke web.config to the LightSwitch application
- Make some more minor edits to the web.config of the LightSwitch application
Next, we download and install the DotNetNuke IFrame module from: http://dnniframe.codeplex.com.
We configure the module to point to the LightSwitch application…
… and it just works.
The sample application also contains the LightSwitch Filter Extension (covered in Using The LightSwitch Filter Extension).
Download
You can download the code at this link.