This project has moved. For the latest updates, please go here.

Session problem in Sharpmap.UI

Topics: General Topics, SharpMap Project, SharpMap v0.9 / v1.x, Web Controls
Aug 10, 2007 at 9:03 AM

I have one another problem.

I am setting some values in session on the default page from where I am initializing the map with the help of map helper class. It hits the map helper class twice, one from the maphelper class and another by call back by maphandler.ashx. ring this second iteration by httphandler the httpcontext.current.session is get cleared. The all values of session will get cleared and set to null. do anybody have some idea regarding this?



Aug 13, 2007 at 4:24 AM
I was having the same problem, but only in IE, everything worked fine in FireFox. The solution is to use HttpContext.Current.Request.Cookies("cookie").Value
session cookies instead of variables. For some reason (I'm not the greatest on the inner workings of .net) each call to the maphandler resets the session variable. I placed some alert boxes in my code to trace my session variables through and sure enough on the initial call it would be the correct value, then while the map was drawing it would reset to null, or zero. Hope this helps.
Aug 13, 2007 at 5:39 AM
hey djjeffg382 thanks fo you r reply.

I got the solution for this problem. This problem is due to the httphandler, this httphandler clears all session values.
the solution is to implement "IRequiresSessionState" interface in the handler.
in the ashx file include using System.Web.SessionState;
and on the class declaration of handler
"public class MapHandler : IHttpHandler"
implement the interface as

"public class MapHandler : IHttpHandler,IRequiresSessionState"
this IRequiresSessionState will help in persisting session state.
Hope this code will help you.
Apr 23, 2009 at 10:51 PM
Why call the map helper class twice, one from the maphelper class and another by call back by maphandler.ashx?

Can i call only once?