416.467.9100 | Dundas Data Visualization | Login
Welcome Guest
This is the support page for the legacy Dundas Dashboard application. For assistance with the current Dundas BI application please click here.
Dashboard v4.0

This site makes extensive use of JavaScript.

Please enable JavaScript in your web browser and reload the page before proceeding.

Using the Enhanced Viewer in ASP.NET Applications

Hide navigation
Modified on Mon, 10 Mar 2014 05:31 PM Categorized as Samples, Viewer
Click to return to: Documentation | Using the Dashboard Viewer in Your Applications


This article shows how to create a bare-bones ASP.NET Web Application project that will embed the Dundas Dashboard Enhanced Viewer. As well, the article shows how to programmatically log in users through both server-side and client-side session generation (using login tokens).

The code in this article is based on the Viewer Integration Sample which is included when you install Dundas Dashboard.



Make sure you have the following prerequisites installed on your computer:

  • Visual Studio 2010 or Visual Studio 2010 Express
  • Microsoft .NET Framework 4.0
  • IIS web server running ASP.NET 2.0 or greater
  • Dundas Dashboard 4.0 or greater

Add a viewer user in Dundas Dashboard

The ASP.NET application will need to be able to log in to your Dundas Dashboard server via a specific local user account that has privileges to view dashboards. The source code which will be presented later is actually hard-coded with an expected local user name and password. You can change these credentials in the code (as will be shown later), or log in to Dundas Dashboard as an administrator and create the expected local user account as follows:

  • Username: viewer
  • Password: 1234
  • Role: Viewer. Make sure you uncheck the option “Is always permitted to login to view dashboards”. This will set up the user as a floating viewer.

See the articles on Managing Users and Licensing for more details.

Obtain the GUID of a dashboard for viewing

The ASP.NET application will essentially load an existing dashboard into the viewer. The source code presented later is hard-coded with an example dashboard GUID which you must replace (as will be shown later).

For now, simply log in and obtain the GUID of any existing dashboard on your Dundas Dashboard server. Save the GUID value in Notepad for later use.

See the example from this article which shows how to obtain the GUID of the Sonatica Executive dashboard (e.g. 7bcebd59-d425-4f29-9ea4-73033d50d515).

Creating the web application

Create a new ASP.NET Web Application project in Visual Studio

Launch Visual Studio and create a new project as follows:

  1. In the New Project screen, select the option to create a new ASP.NET Web Application project.
  2. Enter the following settings, then click OK:
    • Name (of project): EnhancedViewerInWebPage
    • Location: C:\visual studio 2010\Projects (or location of your choice)
    • Solution name: EnhancedViewerInWebPage
    • Create directory for solution: Yes
      New Project in Visual Studio.
  3. The EnhancedViewerInWebPage project and solution are created. In the project, add references to the following assemblies from the Program Files\Dundas Data Visualization Inc\Dundas Dashboard\{InstanceName}\SDK\lib\Server\ folder:
    • Dundas.Dashboard.Extensibility.Server.dll
    • Dundas.Dashboard.Server.Integration.dll
    • ICSharpCode.SharpZipLib.dll

A typical project structure will look like this:

Typical structure for the ASP.NET Web Application project.

Typical structure for the ASP.NET Web Application project.

Add Silverlight to the Default.aspx web page

Add Silverlight to the Default.aspx web page by using HTML:

  1. Open the Default.aspx file in order to edit the web page's markup.
  2. Refer to the article How to: Add Silverlight to a Web Page by Using HTML. Copy the markup presented in the Code section and use it to update the markup in your Default.aspx. Be careful not to overwrite the Page directive which is the first line of your Default.aspx file.
  3. Modify the div element by replacing it with the markup listed below (take note of the dynamic parameters passed to source and initParams).

Add code-behind to the Default.aspx web page

Follow these steps to add code-behind to the Default.aspx web page:

  1. Open the Default.aspx.cs file to edit the code-behind so that it resembles the code shown below.
  2. Change the ServerUri value to the server URL for your Dundas Dashboard instance. Note that this URL must have the slash character at the end.
  3. Change the dashboardContentId value to the GUID of a dashboard to be loaded (which you obtained previously).
  4. Compile and build the solution.

The viewerUsername and viewerPassword values should already be correct if you followed all of the setup steps presented earlier.

Tip: The code below includes an example of using the delete other sessions option, as well using login tokens for client-side login session generation. Please see the comments in the code listing for details.

Tip: If you encounter formatting problems when copying the following code listing to Visual Studio, try copying and pasting to Microsoft WordPad first, then copy and paste from WordPad to Visual Studio.

using System; using Dundas.Dashboard; using Dundas.Dashboard.Integration;

namespace EnhancedViewerInWebPage { public partial class _Default : System.Web.UI.Page { // Application methods #region Methods

protected void Page_Load(object sender, EventArgs e) { // Initialize server parameters to where Dundas Dashboard is installed this.ServerUri = new Uri("http://dashsvr:7000/");

// Initialize the Dundas Dashboard integration interface IntegrationHelper.ServerUri = this.ServerUri;

// Initialize the viewer username/password string viewerUsername = "viewer"; string viewerPassword = "1234";

// Initialize the startup Dashboard Id (this Dashboard will be displayed when Viewer first loads) Guid dashboardContentId = new Guid("7bcebd59-d425-4f29-9ea4-73033d50d515");

// Control viewer features by passing in additional feature parameters // For additional parameters, refer to: http://support.dundas.com/Dashboard4.EnhancedViewer_Vieweraspx.ashx string viewerFeatures = "IsLogoVisible=false;IsToolbarVisible=false;IsNavigationVisible=false";

// For floating viewer accounts, the deleteOtherSession will work as follows: // true : Force the oldest session to be automatically deleted // false : Throw error LoginFailureReason.ViewerLicenseLimitReached

// For concurrent accounts, the deleteOtherSession will work as follows: // true : Generate a new session, and remove any previously signed in session for the same user // false : Throw error LoginFailureReason.TooManySessions

// If there are no more licenses, do not automatically delete other sessions. bool deleteOtherSessions = false;

// Below are two methods of logging in a user. Use one or the other. DO NOT use both methods during initialization of the viewer. // Method #1 is preferred for typical scenarios (i.e. embedding viewer in your own web page portal) // To test the difference between the methods, toggle the flag below to see the behaviour.

// Default to use Method #1 bool useMethod1 = true;

// Use the appropriate method based on above flag if (useMethod1) { // --------------------------------------------------- // METHOD #1: CLIENT-SIDE SESSION GENERATION // Request for a login token Guid loginToken = IntegrationHelper.GetLocalLoginToken(viewerUsername, viewerPassword);

// Client-side session generation will request a new session at the client level by passing in a temporary login token. // A valid session will only be generated, after the viewer control has loaded. // If a session is successfully created, a license will be consumed. Because a session is created at the client level, // a new license will not be consumed on subsequent request on the same client computer.

// Build the init params using the loginToken this.InitParams = string.Format("ddAppLoaderModule=1,Dd_ContentType=Dashboard,ServerUri={0},dwLoginToken={1},Dd_ContentId={2},dwDeleteOtherSessions={3},Dd_ViewerFeatures={4}", this.ServerUri, loginToken, dashboardContentId, deleteOtherSessions ? 1 : 0, viewerFeatures); // --------------------------------------------------- } else { // --------------------------------------------------- // METHOD #2: SERVER-SIDE SESSION GENERATION

// Server-side session generation will request a new session at the server level. // If a session is successfully created, a license will be consumed. Because a session is created at the // server level every successful request will consume a new license. // IMPORTANT: Use this method if you have a valid reason to do so.

// Attempt to log in using username and password LoginStatus loginStatus = IntegrationHelper.LoginLocal(viewerUsername, viewerPassword, deleteOtherSessions);

// Ensure no failures are encountered logging in viewer user if (loginStatus.LoginFailureReason != LoginFailureReason.None) { throw new ArgumentException("Could not create session: " + loginStatus.LoginFailureReason.ToString(), "dwSessionId"); }

// Retrieve the login session's Id Guid sessionId = loginStatus.SessionId;

// Build the init params using sessionId this.InitParams = string.Format("ddAppLoaderModule=1,Dd_ContentType=Dashboard,ServerUri={0},dwSessionId={1},Dd_ContentId={2},Dd_ViewerFeatures={3}", this.ServerUri, sessionId, dashboardContentId, viewerFeatures); // --------------------------------------------------- }



// Properties for use in the .aspx file #region Properties

/// /// Gets or sets the server URI. /// /// The server URI. public Uri ServerUri { get; set; }

/// /// Gets the dashboard viewer URI. /// /// The dashboard viewer URI. public Uri DashboardViewerUri { get { return new Uri(string.Format("{0}ClientBin/Dundas.Dashboard.AppLoader.xap", ServerUri.ToString())); } }

/// /// Gets or sets the init params. /// /// The init params. public string InitParams { get; set; }

#endregion } }


For the “InitParams” string, you can use the options specified below, or any of the URL parameter options supported by Viewer.aspx.

ddAppLoaderModuleThe app loader module id.
dwLoginTokenA login token for a client-side session.
dwDeleteOtherSessionsIndicates whether to delete other login sessions to ensure there will be a license available.
ServerUriThe base URI of the Dundas Dashboard instance.

Testing the web application in a browser

You can now publish the web application project and test it from a web browser:

  1. Deploy the EnhancedViewerInWebPage project to IIS.
  2. If Dundas Dashboard is running on a different port or server than where your Enhanced Viewer project is, you may need to create a Cross-Domain Policy file. For more details about cross-domain security, also see the Viewer Integration Sample.

As an example, on a server running IIS7, the web application project can be deployed under the same website where Dundas Dashboard is setup:

IIS application for Enhanced Viewer project.

IIS application for Enhanced Viewer project.

Testing the web application in a browser.

Testing the web application in a browser.

Related topics

Click to return to: Documentation | Using the Dashboard Viewer in Your Applications

About Dundas | Contact Us Follow us on Twitter! | Privacy Statement | Report Site Issues

Copyright © 2009-2014 Dundas Data Visualization, Inc.