Hi,
We have set the value of the property DrawingExceptionMode of an instance of Layer class to ThinkGeo.MapSuite.Core.DrawingExceptionMode.ThrowException that forces the thrown of an exception whenever there is a error while drawing a layer. On the server side the exception is thrown but the result is an HTTP 200 response image with the exception drawn directly on that image (the request is made to tile_GeoResource.axd handler). We don’t want this behavior. We would like to return HTTP 500 error messages whenever an exception is raised during layer drawing.
Can we configure something to activate this behavior or it must be achieved with custom code?
Best Regards,
BdaF
Return HTTP 500 response message when exception is raised while drawing layer
Hi BdaF,
I think you can implement your custom layer which inherit from ThinkGeo.MapSuite.Core.Layer, then you can override DrawExceptionCore function and generate your exception image and draw it in tile by canvas.DrawScreenImageWithoutScaling function.
Wish that’s helpful.
Regards,
Don
Hi Don,
It looks like i wasn’t clear enough.
The configuration of that layer is ok. It throws an exception whenever there is an error while drawing the layer (value property of DrawingExceptionMode = ThinkGeo.MapSuite.Core.DrawingExceptionMode.ThrowException). That is the behavior that we want.
We’re using ThinkGeo Web Edition that requests tiles to the handler tile_GeoResource.axd. The HTTP image requests are received by that handler and the rendering process is performed there. At some time on that process, FeatureLayer.Draw(…) method is called (I suppose) that raises and exception if the layer is configured like I’ve said on the last paragraph and there is any error while drawing features. The problem is that after the exception is thrown, it seems like there is some code on that process that catches the exception and returns a HTTP 200 message with the exception error message drawn on a image. We want this behavior on development environment but on production we want to return HTTP 500 error messages to the client side omitting verbose error messages. That is a security issue that we want to avoid.
Hope you can understand what we want with this description.
Best regards,
BdaF
Hi Badf,
I am sorry it looks I misunderstand your issue.
Do you meant, currently you set layer.DrawingExceptionMode = DrawingExceptionMode.ThrowException, when exception thrown, it will draw a HTTP 200 on tiles and you want to use HTTP 500 information instead of it?
I tried to reproduce that but it looks I haven’t reproduced that succeed, please see my code and if possible modify it to let me can reproduced that.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(@“D:\nonexistent.shp”);
LayerOverlay overlay = new LayerOverlay();
overlay.Layers.Add(layer);
layer.DrawingExceptionMode = DrawingExceptionMode.ThrowException;
Map1.CustomOverlays.Add(overlay);
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = new RectangleShape(-2000000, 2000000, 2000000, -2000000);
Map1.MapUnit = GeographyUnit.Meter;
}
}
Regards,
Don
Don,
I created this topic in regard to what I’ve reported on ticket thinkgeo.com/forums/MapSuite…fault.aspx
You must provoke errors while rendering images from client HTTP Requests to the handler tile_GeoResource.axd. If you reproduce the error described on that ticket you will see the error message rendered directly on the image returned from the server. That image is the result of HTTP 200 response message. We want to return HTTP 500 response messages and avoid the disclosure of the internal error to the user.
Regards,
BdaF
Hi BdaF,
I think it’s hard to implement, because under currently structure we have to response an image to client side but cannot response a 500 error message.
I will discuss about this with our developers and reply you after that.
Regards,
Don
Hi BdaF,
Today I discuss this with our developers, we cannot find a workaround for that now.
Throw exception is provided by Layer of MapSuiteCore, but in WebEdition the map is designed to keep return images with 200 message, so we cannot implement that by inherit and override from HttpHandler.
I am sorry about that.
Regards,
Don
Hi Don,
Ok.
We will likely submit an enhancement proposal for next versions of ThinkGeo.
Best Regards,
BdaF
Hi BdaF,
We’re glad to get any enhancement proposal from our user.
Regards,
Don