How to create my own website to access Fusion viewer of AIMS?

By Daniel Du

The fusion viewer has a pretty long URL, I want to create my own website instead of the the long address, it is possible ?

The answer is YES, the simplest way(although not a very elegant way) is to can create an website and use Response.Redirect(), referring to the Fusion viewer.

Sometimes, you need to authenticate user first, in that case, you can implement your authentication function yourself, once authentication failed, just stop running the page by Response.End().

To setup the website, you need to setup a website and create a webform(default.aspx), create bin folder and copy dlls from www/mapviewernet/bin

Here is  the code snippet, it uses MapGuide Enterprise 2010, and it also applies to other versions including MapGudie Enterprise 2011, Autodesk Infrastructure Map Server 2012 and 2013 with minor changes.

 

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using OSGeo.MapGuide;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        //Authentication goes here,

        // you will need to implement your authentication yourself

        if(Authenticated() == false)

        {

            //if authentication failed, return

       
     Response.End();

        }

 

        string webLayout = "Library://Samples/Sheboygan/Layouts/

            TestFlex.ApplicationDefinition";

        string defaultUser = "Administrator";

        string defaultPassword = "admin";

        try

        {

            MapGuideApi.MgInitializeWebTier(@"C:\Program Files

                \Autodesk\MapGuideEnterprise2010

                \WebServerExtensions\www\webconfig.ini");

 

            MgUserInformation userInfo =

                new MgUserInformation(defaultUser, defaultPassword);

            MgSite site = new MgSite();

            site.Open(userInfo);

            string sessionId = site.CreateSession();

 

 

            Response.Redirect("http://localhost/mapguide2010/

                fusion/templates/mapguide/slate/index.html

                        ?ApplicationDefinition=" + webLayout

                        + "&Session=" + sessionId);

        }

        catch (Exception ex)

        {

            Response.Write(ex.Message);

        }

    }

 

    public bool Authenticated()

    {

        //implement your authentication logic yourself

        // ….

 

        return true;

    }

}


Comments

3 responses to “How to create my own website to access Fusion viewer of AIMS?”

  1. Hey.
    I’m a noob at Mapguide and i just started to work with MG OpenSource. So i would like to ask you if this is applicable to open source version as well. Because in MGOS (2.4 version) i can’t seem to find or enable the authentication settings (login) for fusion layout.This question is probably more suitable for MGOS forum but since i read this blog article of yours (and i really like your articles-very informative) i wanted to ask you directly.
    Thanks!

  2. This code snippet is not tested on MapGuide OpenSource, but yes, it should work with minor changes.
    Thanks,
    Daniel

  3. Daniel,
    I am using .NET ASP C#. Will it work with that as well.
    I am new to Mapguide and .Net
    At this moment i am using anonymous user name and paswword. But I want to use authentication of user which are created in Mapguide Administrator as per role ect.
    Regards,
    Anand

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading