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;
}
}