Code:
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
{
public string sessionId;
public string webLayout;
public string url;
protected void Page_Load(object sender, EventArgs e)
{
//string config = @"c:Arquivos de programasMapGuideOpenSourceWebServerExtensionswwwwebconfig.ini";
string config = @"c:\Arquivos de programas\MapGuideOpenSource\WebServerExtensions\www\webconfig.ini";
MapGuideApi.MgInitializeWebTier(config);
MgSite site = new MgSite();
MgUserInformation info = new MgUserInformation("Administrator", "admin");
site.Open(info);
site.Open(info);
sessionId = site.CreateSession();
webLayout = "Library://YorPaste/YourLayout.WebLayout";
url = "/mapguide/mapviewerajax/?SESSION=" + sessionId + "&WEBLAYOUT=" + webLayout;
}
}
In CS Page...
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body bgcolor=blue>
<form id="form1" runat="server">
<p>
<asp:Label ID="lblURL" runat="server" Text="Label"></asp:Label>
</p>
<iframe id="viewerFrame"
width="100%"
height="80%"
frameborder="0"
scrolling="no"
src="<% = url %>">
</iframe>
</form>
</body>
</html>
In Aspx html
Sample of code for use Mapguide Enterprise with Visual Studio .NET 2005 C#