Our team recently updated our project to have the sessionState mode to StateServer and changed all needed classes to be Serializable. As a result our MapShapeLayer and InMemoryFeatureLayers are not displaying. We are adding them to LayerOverlay’s before adding them as CustomOverlays to the Map control. I have attempted to follow other forums to no avail. I have also verified that the shapes display in other sessionState mode like InProc. Am I missing something?
MapShapeLayer and InMemoryFeatureLayer are not displaying after changing sessionState mode to StateServer
Hi Neil,
I did quickly research today, it looks sometimes the different session save mode will effect the JavaScript code run result, but I hadn’t find more detail information about that.
So I want to make sure some items:
-
What’s the dll version you are using.
-
Could you please build a simple sample can reproduce that, so we don’t need ask more detail about the code.
-
Let us know your server setting, so our developer can try to reproduce that.
Regards,
Don
Hi Don,
Thank you for the reply.
-
The current version of our dlls is 9.0.0.541
-
I will look into building a sample project. The page we have it on is rather complex making it difficult to possibly create.
-
I am not sure what you mean by server setting, will you please elaborate?
Thanks,
Neil
Hi Neil,
Thanks for you information.
Attached is my test sample, which save session in ASP.NET State Service of localhost.
But it render a ShapeFileFeatureLayer and an InmemoryFeatureLayer correct, could you please view my test sample and modify it to reproduce your issue?
5895.zip (172.3 KB)
Regards,
Don
Hi Don,
I had some time to explore the issue further and was able to replicate the issue with the sample project you sent me. I will include the code below. For your information, I am primarily using Google Chrome. Whenever I run the project and the issue occurs I receive the “Failed to load resource: the server responded with a status of 500 ()” with the link being “adornment_GeoResource.axd”. I select the missing reference and in a new tab the message appears “GeoImage’s native image cannot be null.” The times when this issue occurs for us is with the Adornment Overlay, MapShapesLayer added to a LayerOverlay, and Features being added to a FeatureOverlay then transferred to the HighlightOverlay. I am wondering if it has something to do with the custom styles or the zoom styling because we apply styling to each of the objects above. Anyway, we need to be using StateServer for the project. Any help will be greatly appreciated.
Here is the code, it’s not pretty but it gets the job done. All Thinkgeo Packages are version 10.1.0
Default.aspx.cs
using System;
using ThinkGeo.MapSuite;
using ThinkGeo.MapSuite.Layers;
using ThinkGeo.MapSuite.Styles;
using ThinkGeo.MapSuite.WebForms;
using ThinkGeo.MapSuite.Shapes;
using ThinkGeo.MapSuite.Drawing;
using System.IO;
using System.Drawing;
namespace Test
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
// Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’s unit of measure is inherently in.
Map1.MapUnit = GeographyUnit.DecimalDegree;
LayerOverlay layerOverlay = new LayerOverlay();
//1. Uncomment this out to show the project working with StateServer ///////////////////// Shows the layer working with StateServer//////////////////////////////////// //ShapeFileFeatureLayer shapeFileLayer = new ShapeFileFeatureLayer(MapPath(@"App_Data\states.shp")); //shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = WorldStreetsAreaStyles.Military(); //shapeFileLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //////////////////////////////////////////////////////////////////////////////////////////////////
//2. Uncomment this out to show the project not working with StateServer ///////////////////// Shows the layer not working with StateServer//////////////////////////////// ShapeFileFeatureLayer shapeFileLayer = new ShapeFileFeatureLayer(MapPath(@"App_Data\states.shp"), MapPath(@"App_Data\states.idx"), GeoFileReadWriteMode.Read, System.Text.Encoding.Default); shapeFileLayer.Name = "Rivers"; ZoomLevel objZoom = shapeFileLayer.ZoomLevelSet.ZoomLevel01; objZoom.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LineStyle objStyle = default(LineStyle); objStyle = new LineStyle(new GeoPen(GeoColor.FromArgb(100, GeoColor.StandardColors.DarkBlue))); objZoom.CustomStyles.Add(objStyle); objZoom.CustomStyles.Add(GetHaloLabelRender(6.5F, "FULLNAME", GeoColor.StandardColors.DarkBlue)); //-- Add layer to map shapeFileLayer.ZoomLevelSet.CustomZoomLevels.Add(objZoom); //shapeFileLayer.FeatureSource.Projection = mobjGIS.GetProjection(strFile); //objOverlay.Layers.Add(shapeFileLayer); //////////////////////////////////////////////////////////////////////////////////////////////////
layerOverlay.Layers.Add(shapeFileLayer);
InMemoryFeatureLayer imf = new InMemoryFeatureLayer(); imf.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; imf.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; imf.InternalFeatures.Add(new Feature(new RectangleShape(-100, 50, -80, 30))); layerOverlay.Layers.Add(imf);
LegendAdornmentLayer objLegend = BuildLegend(ref Map1, ref layerOverlay); Map1.AdornmentOverlay.Layers.Add("LegendLayer", objLegend);
Map1.CustomOverlays.Add(layerOverlay);
//shapeFileLayer.Open(); //Map1.CurrentExtent = shapeFileLayer.GetBoundingBox(); Map1.CurrentExtent = new RectangleShape(-178.215027, 71.406647, -66.969849, 18.924782); } } catch (Exception ex) {
} }
private TextStyle GetHaloLabelRender(float FontWidth, string strRenderField, GeoColor TextColor, bool blnOnTop = false) { if (blnOnTop == true) { return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, 10, 10); } else { return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, -10, -10); } }
public LegendAdornmentLayer BuildLegend(ref Map objMap, ref LayerOverlay objLayersOverlay, RectangleShape objExtent = null, double dblWidth = 0, GeographyUnit objUnit = GeographyUnit.Unknown, string strLegLocationIndex = "") { try { //Building the Adornament layer details. LegendItem objTitle = new LegendItem(); objTitle.TextStyle = new TextStyle("Map Legend", new GeoFont("Arial", 11, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.SimpleColors.Black));
LegendAdornmentLayer objLegend = new LegendAdornmentLayer();
AdornmentLocation objLocation = AdornmentLocation.LowerLeft; if (strLegLocationIndex != "") { objLocation = AdornmentLocation.CenterLeft; if (objLocation == AdornmentLocation.UseOffsets) return null; //Basically acts like there was a problem.
if (objLocation.ToString().ToUpper().Contains("RIGHT")) objLegend.XOffsetInPixel = -5; else if (objLocation.ToString().ToUpper().Contains("LEFT")) objLegend.XOffsetInPixel = 5; else objLegend.XOffsetInPixel = 0;
if (objLocation.ToString().ToUpper().Contains("UPPER")) objLegend.YOffsetInPixel = 5; else if (objLocation.ToString().ToUpper().Contains("LOWER")) if (objLocation.ToString().ToUpper().Contains("LEFT")) objLegend.YOffsetInPixel = -17; else objLegend.YOffsetInPixel = -5; else objLegend.YOffsetInPixel = 0;
} else //Default is Lower Left { objLegend.XOffsetInPixel = 5; objLegend.YOffsetInPixel = -17; }
objLegend.Location = objLocation; objLegend.BackgroundMask = AreaStyles.CreateLinearGradientStyle(new GeoColor(255, 255, 255, 255), new GeoColor(255, 230, 230, 230), 90, GeoColor.SimpleColors.Black); objLegend.Title = objTitle; objLegend.Transparency = 220F;
double dblMapScale = 0;
if ((objExtent == null) == false) { dblMapScale = objMap.ZoomLevelSet.GetZoomLevel(objExtent, dblWidth, objUnit, 96).Scale; }
foreach (Layer objLayer in objLayersOverlay.Layers) { if (typeof(ShapeFileFeatureLayer) == objLayer.GetType()) {
ShapeFileFeatureLayer objFLayer = (ShapeFileFeatureLayer)objLayer; ZoomLevel objZoom = null; int intZoom = 0;
if (objFLayer.ZoomLevelSet.CustomZoomLevels.Count != 0) { if (objFLayer.ZoomLevelSet.CustomZoomLevels.Count > 1) { for (intZoom = 0; intZoom <= objFLayer.ZoomLevelSet.CustomZoomLevels.Count - 1; intZoom++) { objZoom = objFLayer.ZoomLevelSet.CustomZoomLevels[intZoom]; if (objZoom.Scale >= dblMapScale) { break; // TODO: might not be correct. Was : Exit For } } } else { objZoom = objFLayer.ZoomLevelSet.CustomZoomLevels[0]; }
//Too foreach (ThinkGeo.MapSuite.Styles.Style objCustomStyle in objZoom.CustomStyles) { string strVName = ""; string strfilepath = "";
GeoImage objImage = new GeoImage(); PointStyle objStyleImg = new PointStyle(); LegendItem objLegendItem = new LegendItem(); if ((objCustomStyle is ValueStyle) == true) { if (objLayer.IsVisible == true) { GeoImage objGeoNull = null; objLegendItem = BuildLegendItem(objLayer.Name, objGeoNull, 0, false); objLegend.LegendItems.Add(objLegendItem);
ValueStyle objValueR = (ValueStyle)objCustomStyle; foreach (ValueItem objValue in objValueR.ValueItems) { if (objValue.CustomStyles[0].Name.Length == 0) { strVName = objValue.Value; } else { strVName = objValue.CustomStyles[0].Name; }
//This is set in the render code to hide value render items in needed if (strVName != "NOLEGENDITEM") { GeoImage objGeoImage = new GeoImage(); foreach (ThinkGeo.MapSuite.Styles.Style objStyle in objValue.CustomStyles) { if (objStyle is TextStyle == false) { objGeoImage = SaveStyleImage(objStyle); } } objLegendItem = BuildLegendItem(strVName, objGeoImage, 35); objLegend.LegendItems.Add(objLegendItem); } } } } else if ((objCustomStyle is ClassBreakStyle) == true) { ClassBreakStyle objValueR = (ClassBreakStyle)objCustomStyle; //ClassBreak objValue = default(ClassBreak); strVName = "";
if (objLayer.IsVisible == true) { GeoImage objGeoNull = null; objLegendItem = BuildLegendItem(objLayer.Name, objGeoNull, 0, false); objLegend.LegendItems.Add(objLegendItem);
foreach (ClassBreak objValue in objValueR.ClassBreaks) { if (objValue.CustomStyles[0].Name.Length == 0) { strVName = objValue.Value.ToString(); } else { strVName = objValue.CustomStyles[0].Name; }
GeoImage objGeoImage = new GeoImage(); foreach (ThinkGeo.MapSuite.Styles.Style objStyle in objValue.CustomStyles) { if (objStyle is TextStyle == false) { objGeoImage = SaveStyleImage(objStyle); } } objLegendItem = BuildLegendItem(strVName, objGeoImage, 35); objLegend.LegendItems.Add(objLegendItem); } }
} else { if ((objCustomStyle is TextStyle) == false) { foreach (ThinkGeo.MapSuite.Styles.Style objStyle in objZoom.CustomStyles) { if (objLayer.IsVisible == true) { if (objStyle is TextStyle == false & objStyle is ValueStyle == false) { GeoImage objGeoImage = new GeoImage(); objGeoImage = SaveStyleImage(objCustomStyle);
if (objStyle.Name.Length != 0) objLegendItem = BuildLegendItem(objStyle.Name + "(" + objLayer.Name + ")", objGeoImage); else objLegendItem = BuildLegendItem(objLayer.Name, objGeoImage); objLegend.LegendItems.Add(objLegendItem); } } } } } } }
} }
objLegend.Height = GetLegendHeight(objLegend); objLegend.Width = GetLegendWidth(objLegend);
return objLegend; } catch (Exception ex) {
return null; } }
private LegendItem BuildLegendItem(string strItemName, GeoImage objGeoImage, int intLeftPadding = 0, bool blnImage = true) { try { LegendItem objLegendItem = new LegendItem(); GeoImage objImage = new GeoImage(); PointStyle objStyleImg = new PointStyle();
if (blnImage == true) { objImage = objGeoImage; objStyleImg = new PointStyle(objImage); objLegendItem.ImageStyle = objStyleImg; } objLegendItem.LeftPadding = intLeftPadding;
objLegendItem.TextStyle = new TextStyle(strItemName, new GeoFont("Arial", 8.5F, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.SimpleColors.Black));
return objLegendItem; } catch (Exception ex) { return null; } }
private GeoImage SaveStyleImage(ThinkGeo.MapSuite.Styles.Style objStyle) { try { Bitmap objBMP = new Bitmap(14, 14); RectangleShape objRec = new RectangleShape(0, 14, 14, 0); DrawingRectangleF objRecF = new DrawingRectangleF(7, 7, 12, 12); GeoImage objGeoImage = new GeoImage();
PlatformGeoCanvas objCanvas = new PlatformGeoCanvas();
objCanvas.BeginDrawing(objBMP, objRec, GeographyUnit.Feet); objStyle.DrawSample(objCanvas, objRecF); objCanvas.EndDrawing();
MemoryStream msStream = new MemoryStream(); objBMP.Save(msStream, System.Drawing.Imaging.ImageFormat.Tiff); objGeoImage = new GeoImage(msStream);
return objGeoImage;
} catch (Exception ex) { return null; } }
public int GetLegendHeight(LegendAdornmentLayer objLengend) { try { PlatformGeoCanvas objGDICanvas = new PlatformGeoCanvas(); int intTextHeight = (int)objLengend.Title.Height;// +(int)objLengend.Title.Height;
foreach (LegendItem objItem in objLengend.LegendItems) { int intHeight = (int)objGDICanvas.MeasureText(objItem.TextStyle.TextColumnName, objItem.TextStyle.Font).Height; intTextHeight = intTextHeight + intHeight + intHeight; }
if (intTextHeight != 0) return intTextHeight; else return 100; } catch (Exception ex) { return 100; } }
public int GetLegendWidth(LegendAdornmentLayer objLegend) { try { PlatformGeoCanvas objGDICanvas = new PlatformGeoCanvas(); int intTextWidth = (int)objGDICanvas.MeasureText(objLegend.Title.TextStyle.TextColumnName, objLegend.Title.TextStyle.Font).Width;
foreach (LegendItem objItem in objLegend.LegendItems) { int intLength = (int)objGDICanvas.MeasureText(objItem.TextStyle.TextColumnName, objItem.TextStyle.Font).Width; if (intLength > intTextWidth) intTextWidth = intLength;
}
if (intTextWidth < 180 && (intTextWidth + 60) < 180) return 180; else if (intTextWidth != 0) return intTextWidth + 60; else return 180; } catch (Exception ex) { return 180; } }
}
}
Default.apsx
<%@ Page Title=“Home Page” Language=“C#” MasterPageFile="~/Site.Master" AutoEventWireup=“true” CodeBehind=“Default.aspx.cs” Inherits=“Test._Default” %>
<%@ Register Assembly=“ThinkGeo.MapSuite.WebForms” Namespace=“ThinkGeo.MapSuite.WebForms” TagPrefix=“cc1” %>
<asp:Content ID=“BodyContent” ContentPlaceHolderID=“MainContent” runat=“server”>
<div> <cc1:Map ID="Map1" runat="server" Height="600px" Width="800px"></cc1:Map> </div>
</asp:Content>
Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<sessionState mode="StateServer" customProvider="DefaultSessionProvider" timeout="120" stateNetworkTimeout="20" >
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpHandlers>
<add path="*_GeoResource.axd" verb="*" type="ThinkGeo.MapSuite.WebForms.GeoResourceFactory" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="GeoResource" preCondition="integratedMode" path="*_GeoResource.axd" verb="*" type="ThinkGeo.MapSuite.WebForms.GeoResourceFactory" />
</handlers>
</system.webServer>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Thank you,
Neil
Hi Neil,
Thanks for your code, your sample have two problems:
- Just follow you comment information, the item 2 not working is because the data is area but you just add a line style.
Please use this code to make it works:
AreaStyle objStyle = default(AreaStyle);
objStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColor.StandardColors.DarkBlue)));
- The 500 error is from the legend adornment layer, I had reproduced that. I found only when you render the GeoImage as ImageStyle and session state equal StateServer, it can be reproduce. We will look into it.
For now you can directly assign the areaStyle or lineStyle to the ImageStyle of LegendItem instead of build a GeoImage.
Regards,
Don
Hi Neil,
This 500 error had been fixed in our latest mapsuite 10.0 pre-release version. I guess it can be downloaded in 1 or 2 days.
Regards,
Don
Hi Don,
Thank you for letting me know! That’s great you guys were able to get it fixed. Thank you for pointing out my silly mistake with line and area styles being mixed up. I also noticed using StateServer with the HighlightOverlay and LayerOverlay display the features on initial loading of our web page. It is only when we use DoPostBack and Update Panels when the features do not display on the map. The Overlays both work with InProc mode with sessionState. I will keep looking into this but I was curious if you have ever seen this before?
Thank you,
Neil
Hi Neil,
We hadn’t met this before because we hadn’t used the StateServer mode, thanks to let us know this scenario.
Any question please let us know.
Regards,
Don
Hi Don,
I converted the sample project to show the issue we are having. The Overlay features will display when sessionState is in “InProc” mode but not “StateServer” when the button is clicked. I did noticed when directly adding items into the Overlay and not passing it through the session the issue does not persist. We are passing most things by session because of the complexity of the code on our page. Any solutions would be greatly appreciated.
Default.aspx
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test._Default" %>
<%@ Register Assembly="ThinkGeo.MapSuite.WebForms" Namespace="ThinkGeo.MapSuite.WebForms" TagPrefix="cc1" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div>
<cc1:Map ID="Map1" runat="server" Height="600px" Width="800px"></cc1:Map>
</div>
<asp:Button ID="Button" runat="server" OnClick="Button_Click" Text="Add Layer"/>
</asp:Content>
Default.aspx.cs
using System;
using ThinkGeo.MapSuite;
using ThinkGeo.MapSuite.Layers;
using ThinkGeo.MapSuite.Styles;
using ThinkGeo.MapSuite.WebForms;
using ThinkGeo.MapSuite.Shapes;
using ThinkGeo.MapSuite.Drawing;
using System.IO;
using System.Drawing;
namespace Test
{
public partial class _Default : System.Web.UI.Page
{
private LayerOverlay layerOverlay;
private FeatureOverlay featureOverlay;
protected void Page_Init(object sender, System.EventArgs e)
{
layerOverlay = (LayerOverlay)Session["layerOverlay"];
featureOverlay = (FeatureOverlay)Session["featureOverlay"];
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
// Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’s unit of measure is inherently in.
Map1.MapUnit = GeographyUnit.DecimalDegree;
layerOverlay = new LayerOverlay();
//Just to Show how Items are able to load before a postback
InMemoryFeatureLayer imf = new InMemoryFeatureLayer();
imf.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
imf.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
imf.InternalFeatures.Add(new Feature(new RectangleShape(-100, 50, -80, 30)));
layerOverlay.Layers.Add(imf);
Map1.CustomOverlays.Add(layerOverlay);
featureOverlay = Map1.HighlightOverlay;
Map1.CurrentExtent = new RectangleShape(-178.215027, 71.406647, -66.969849, 18.924782);
Session.Remove("layerOverlay");
Session.Add("layerOverlay", layerOverlay);
Session.Remove("featureOverlay");
Session.Add("featureOverlay", featureOverlay);
}
}
catch (Exception ex)
{
}
}
private TextStyle GetHaloLabelRender(float FontWidth, string strRenderField, GeoColor TextColor, bool blnOnTop = false)
{
if (blnOnTop == true)
{
return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, 10, 10);
}
else
{
return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, -10, -10);
}
}
//When sessionState is in InProc these layers will display. When sessionState is in StateServer they will not.
protected void Button_Click(object sender, EventArgs e)
{
//Adds the States Shapefile
ShapeFileFeatureLayer shapeFileLayer = new ShapeFileFeatureLayer(MapPath(@"App_Data\states.shp"), MapPath(@"App_Data\states.idx"), GeoFileReadWriteMode.Read, System.Text.Encoding.Default);
ZoomLevel objZoom = shapeFileLayer.ZoomLevelSet.ZoomLevel01;
objZoom.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
AreaStyle objStyle = default(AreaStyle);
objStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColor.StandardColors.DarkBlue)));
objZoom.CustomStyles.Add(objStyle);
objZoom.CustomStyles.Add(GetHaloLabelRender(6.5F, "FULLNAME", GeoColor.StandardColors.DarkBlue));
//-- Add layer to map
shapeFileLayer.ZoomLevelSet.CustomZoomLevels.Add(objZoom);
layerOverlay.Layers.Add(shapeFileLayer);
//Adds a FeatureOverlay Point that represents the Highlight Overlay
PointShape objPoint = new PointShape(-100, 45);
GeoColor objPointColor = new GeoColor(255, 0, 0);
PointStyle objPointStyle = new PointStyle((PointSymbolType)0, new GeoSolidBrush(objPointColor), 6);
Feature pointmap = new Feature(objPoint);
featureOverlay.Features.Add(pointmap);
Session.Remove("layerOverlay");
Session.Add("layerOverlay", layerOverlay);
Session.Remove("featureOverlay");
Session.Add("featureOverlay", featureOverlay);
}
}
}
Web.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<sessionState mode="StateServer" customProvider="DefaultSessionProvider" timeout="120" stateNetworkTimeout="20" >
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpHandlers>
<add path="*_GeoResource.axd" verb="*" type="ThinkGeo.MapSuite.WebForms.GeoResourceFactory" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="GeoResource" preCondition="integratedMode" path="*_GeoResource.axd" verb="*" type="ThinkGeo.MapSuite.WebForms.GeoResourceFactory" />
</handlers>
</system.webServer>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Thanks,
Neil
Hi Don,
Also one more item. I attempted to upgrade to the newest pre-release version of MapSuite (11.0.0-beta040) and came across the issue "Method not found: ‘Void ThinkGeo.MapSuite.Layers.TileCache.set_JpegQuality(Int16)’ which overlayed the tiles on the map. I did not see a TileCache package on NuGet to download. Am I missing something?
Thank you,
Neil
Hi Neil,
We have reproduced your first issue.
The reason of that is: When you use StateServer, the Map1.HighlightOverlay is serialized to store in Session, but we already have default session for Map1.HighlightOverlay. So the saved session shouldn’t be the same one with our default session, and the saved one cannot sync with the client side.
In fact there are two solutions for your this situation:
a. Don’t need to operate session by code, please refer the sample StateServerSessionTest.zip (177.8 KB)
b. Set InProc mode should be more simpler.
Regards,
Don
Hi Neil,
For your second question, this one issue had been fixed on our WebForms, so you need to update one of the two packages:
Wish that’s helpful.
Regards,
Don
Hi Don,
The updated dlls work and we decided to transition from using the session and just work off of the HighlightOverlay. We have everything working now! Thank you for the all the help.
Regards,
Neil
Hi Neil,
I am glad to hear your project works now.
Any question please feel free to let us know.
Regards,
Don
Hi Ethan and ThinkGeo,
Over the last few months we were working on improving performance on our larger databases. We were noticing it was taking a very long time to load in the tiles and would sometimes error resulting in pink tiles. We finally found what was slowing down the map and that was the “sessionState” mode being set to “StateServer”. Whenever we change back to “InProc” the process of loading the LayerOverlay is substantially increased to acceptable levels. We then were able to track back our conversation about the “sessionState” back to this. Our only problem is we may not be able to use “InProc” with various parts of our project using “StateServer”. We were wondering if you may have a solution or may be working on the control with “StateServer”? Currently we have the 10.3 dlls on our project.
Thank you,
Neil
Hi Neil,
Unfortunately we also don’t have more experiences on “sessionState”, I think it should be controlled by the asp.net.
I found a topic discussed about it here: https://msdn.microsoft.com/en-us/library/ms972429.aspx
It mentioned:
In process. In process will perform best because the session state memory is kept within the ASP.NET process. For Web applications hosted on a single server, applications in which the user is guaranteed to be re-directed to the correct server, or when session state data is not critical (in the sense that it can be re-constructed or re-populated), this is the mode to choose.
Out of process. This mode is best used when performance is important but you can’t guarantee which server a user will request an application from. With out-of-process mode, you get the performance of reading from memory and the reliability of a separate process that manages the state for all servers.
SQL Server. This mode is best used when the reliability of the data is fundamental to the stability of the application, as the database can be clustered for failure scenarios. The performance isn’t as fast as out of process, but the tradeoff is the higher level of reliability.
So I think if the “StateServer” (Out of process) have problem with miss tile, have you tried the SQL Server mode?
Wish that’s helpful and if you found anything we can do for this scenario please feel free to let us know.
Regards,
Ethan
Hi Ethan,
Thank you for the information. We have switched the project over to “InProc” for testing and determining if that will be the best mode to use with sessionState. If we do need to stick with “StateServer” we will look into the information you have mentioned above. Additionally, we will report any findings we have based on your information provided and any we come up with ourselves in case someone else uses “StateServer”.
Thank you,
Neil
Hi Neil,
Thanks for your information. Please let us know if there are any updates.
Thanks
Mark