# Map is sometimes "null" in controller action method

**URL:** <https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008>\
**Category:** MVC\
**Created:** [January 31, 2013, 2:19am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008 "2013-01-31T02:19:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sindre](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/sindre/32/24981_2.png) [@Sindre](https://community.thinkgeo.com/u/Sindre)\
**Post date:** [January 31, 2013, 2:19am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/1 "2013-01-31T02:19:20Z")

</div>

Hello,

I&nbsp;am&nbsp;using&nbsp;the&nbsp;following&nbsp;code&nbsp;to&nbsp;request&nbsp;data&nbsp;from&nbsp;the&nbsp;server:

`map.ajaxCallAction('Action', 'ActionMethod', null, function (ajaxResponse) {...});`

The&nbsp;action&nbsp;method&nbsp;signature&nbsp;is&nbsp;like&nbsp;this:

`[MapActionFilter][OutputCache(Duration = 0, VaryByParam = "None")]public JsonResult ActionMethod(ThinkGeo.MapSuite.MvcEdition.Map map, GeoCollection<object> args) {...}`

Most&nbsp;of&nbsp;the&nbsp;time&nbsp;this&nbsp;works&nbsp;fine,&nbsp;but&nbsp;sometimes&nbsp;"map"&nbsp;is&nbsp;null.&nbsp;Do&nbsp;you&nbsp;have&nbsp;any&nbsp;idea&nbsp;why&nbsp;this&nbsp;can&nbsp;happen?

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [February 1, 2013, 2:17am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/2 "2013-02-01T02:17:58Z")

</div>

Hello&nbsp;Sindre,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post,&nbsp;but&nbsp;sorry,&nbsp;we&nbsp;didn’t&nbsp;recreate&nbsp;your&nbsp;problem&nbsp;with&nbsp;the&nbsp;code&nbsp;you&nbsp;provide.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Is&nbsp;that&nbsp;possible&nbsp;you&nbsp;can&nbsp;provide&nbsp;us&nbsp;a&nbsp;sample&nbsp;that&nbsp;can&nbsp;recreate&nbsp;the&nbsp;problem?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;for&nbsp;the&nbsp;inconvenience.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary&nbsp;

---

<div class="post-metadata">

**Author:** ![Sindre](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/sindre/32/24981_2.png) [@Sindre](https://community.thinkgeo.com/u/Sindre)\
**Post date:** [February 1, 2013, 6:33am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/3 "2013-02-01T06:33:18Z")

</div>

Gary,&nbsp;  
&nbsp;&nbsp;  
&nbsp;As&nbsp;I&nbsp;said,&nbsp;the&nbsp;problem&nbsp;is&nbsp;not&nbsp;consistent.&nbsp;It&nbsp;happens&nbsp;maybe&nbsp;in&nbsp;1&nbsp;out&nbsp;of&nbsp;50&nbsp;times.&nbsp;But&nbsp;when&nbsp;it&nbsp;first&nbsp;happens,&nbsp;all&nbsp;further&nbsp;requests&nbsp;fails&nbsp;(map&nbsp;remains&nbsp;null).

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [February 4, 2013, 3:35am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/4 "2013-02-04T03:35:49Z")

</div>

Hello&nbsp;Sindre,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;further&nbsp;information,&nbsp;"But&nbsp;when&nbsp;it&nbsp;first&nbsp;happens,&nbsp;all&nbsp;further&nbsp;requests&nbsp;fails&nbsp;(map&nbsp;remains&nbsp;null)."&nbsp;this&nbsp;situation&nbsp;looks&nbsp;like&nbsp;session&nbsp;time&nbsp;out,&nbsp;can&nbsp;you&nbsp;check&nbsp;if&nbsp;you&nbsp;can&nbsp;get&nbsp;the&nbsp;session&nbsp;information&nbsp;when&nbsp;the&nbsp;problem&nbsp;happen?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [February 7, 2013, 4:13pm UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/5 "2013-02-07T16:13:54Z")

</div>

I&nbsp;think&nbsp;that&nbsp;I&nbsp;have&nbsp;also&nbsp;seen&nbsp;this&nbsp;issue&nbsp;mostly&nbsp;speaking&nbsp;when&nbsp;the&nbsp;page&nbsp;load&nbsp;for&nbsp;the&nbsp;first&nbsp;time&nbsp;and&nbsp;if&nbsp;there&nbsp;is&nbsp;an&nbsp;ajax&nbsp;request&nbsp;involved&nbsp;like&nbsp;setting&nbsp;the&nbsp;current&nbsp;location&nbsp;on&nbsp;the&nbsp;map.&nbsp;&nbsp;The&nbsp;only&nbsp;way&nbsp;to&nbsp;make&nbsp;it&nbsp;to&nbsp;work&nbsp;is&nbsp;to&nbsp;refresh&nbsp;the&nbsp;page&nbsp;and&nbsp;then&nbsp;the&nbsp;application&nbsp;work&nbsp;as&nbsp;expected.&nbsp;  
&nbsp;&nbsp;  
&nbsp;jm

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [February 12, 2013, 7:15am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/6 "2013-02-12T07:15:28Z")

</div>

Hi&nbsp;Jean-Marie,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Is&nbsp;it&nbsp;possible&nbsp;for&nbsp;you&nbsp;to&nbsp;make&nbsp;a&nbsp;demo&nbsp;and&nbsp;send&nbsp;it&nbsp;to&nbsp;us?&nbsp;I&nbsp;guess&nbsp;that’s&nbsp;the&nbsp;most&nbsp;efficient&nbsp;way&nbsp;to&nbsp;recreate&nbsp;the&nbsp;problem.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Johnny

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [February 12, 2013, 10:45am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/7 "2013-02-12T10:45:12Z")

</div>

Hi&nbsp;Johnny&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;shall&nbsp;try&nbsp;to&nbsp;build&nbsp;a&nbsp;sample&nbsp;for&nbsp;you&nbsp;to&nbsp;test.&nbsp;&nbsp;I&nbsp;ll&nbsp;you&nbsp;know&nbsp;when&nbsp;done&nbsp;  
&nbsp;&nbsp;  
&nbsp;jm.

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [February 13, 2013, 11:12pm UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/8 "2013-02-13T23:12:55Z")

</div>

Hello&nbsp;Jean-marie,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;help,&nbsp;you&nbsp;can&nbsp;send&nbsp;the&nbsp;sample&nbsp;to&nbsp;[forumsupport@thinkgeo.com](mailto:forumsupport@thinkgeo.com).&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [February 21, 2013, 5:32am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/9 "2013-02-21T05:32:36Z")

</div>

Hi,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;do&nbsp;confirm&nbsp;that&nbsp;I&nbsp;have&nbsp;the&nbsp;exact&nbsp;same&nbsp;issue.&nbsp;&nbsp;When&nbsp;using&nbsp;the&nbsp;Ajax&nbsp;call&nbsp;available&nbsp;with&nbsp;the&nbsp;map&nbsp;control.&nbsp;&nbsp;I&nbsp;thought&nbsp;that&nbsp;it&nbsp;was&nbsp;only&nbsp;at&nbsp;page&nbsp;load&nbsp;from&nbsp;server&nbsp;but&nbsp;in&nbsp;fact&nbsp;I&nbsp;have&nbsp;a&nbsp;first&nbsp;call&nbsp;using&nbsp;the&nbsp;Ajax&nbsp;method&nbsp;to&nbsp;locate&nbsp;where&nbsp;the&nbsp;device&nbsp;is&nbsp;currently&nbsp;located.&nbsp;In&nbsp;order&nbsp;to&nbsp;do&nbsp;so&nbsp;I&nbsp;do&nbsp;call&nbsp;the&nbsp;navigator&nbsp;service&nbsp;to&nbsp;get&nbsp;the&nbsp;current&nbsp;device&nbsp;coordinate&nbsp;and&nbsp;then&nbsp;I&nbsp;call&nbsp;the&nbsp;mvc&nbsp;controller&nbsp;where&nbsp;I&nbsp;do&nbsp;some&nbsp;processing&nbsp;then&nbsp;I&nbsp;return&nbsp;the&nbsp;the&nbsp;coordinate&nbsp;for&nbsp;the&nbsp;map&nbsp;to&nbsp;center&nbsp;and&nbsp;zoom&nbsp;to.&nbsp;&nbsp;On&nbsp;the&nbsp;client&nbsp;side&nbsp;I&nbsp;do&nbsp;wait&nbsp;for&nbsp;the&nbsp;map&nbsp;created&nbsp;event&nbsp;before&nbsp;issuing&nbsp;any&nbsp;kind&nbsp;of&nbsp;call&nbsp;to&nbsp;the&nbsp;server.&nbsp;I&nbsp;do&nbsp;this&nbsp;by&nbsp;testing&nbsp;a&nbsp;flag&nbsp;that&nbsp;is&nbsp;set&nbsp;to&nbsp;true&nbsp;when&nbsp;the&nbsp;map&nbsp;created&nbsp;event&nbsp;is&nbsp;triggered&nbsp;if&nbsp;flag&nbsp;false&nbsp;I&nbsp;do&nbsp;use&nbsp;a&nbsp;set&nbsp;timeout&nbsp;to&nbsp;check&nbsp;again&nbsp;after&nbsp;let&nbsp;say&nbsp;250ms.&nbsp;And&nbsp;yes&nbsp;time&nbsp;to&nbsp;time&nbsp;the&nbsp;map&nbsp;parameter&nbsp;of&nbsp;the&nbsp;method&nbsp;inside&nbsp;the&nbsp;mvc&nbsp;controller&nbsp;is&nbsp;null.&nbsp;The&nbsp;result&nbsp;is&nbsp;that&nbsp;after&nbsp;that&nbsp;we&nbsp;get&nbsp;a&nbsp;pink&nbsp;map&nbsp;and&nbsp;nothing&nbsp;work&nbsp;any&nbsp;more&nbsp;only&nbsp;refreshing&nbsp;the&nbsp;page&nbsp;will&nbsp;fix&nbsp;the&nbsp;issue.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Hope&nbsp;this&nbsp;help&nbsp;you&nbsp;to&nbsp;understand&nbsp;the&nbsp;problem&nbsp;better.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Jm

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [February 22, 2013, 4:27am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/10 "2013-02-22T04:27:21Z")

</div>

Hi&nbsp;Jm,&nbsp;  
&nbsp;&nbsp;  
&nbsp;To&nbsp;make&nbsp;sure&nbsp;I&nbsp;understood&nbsp;you&nbsp;clearly,&nbsp;please&nbsp;allow&nbsp;me&nbsp;to&nbsp;do&nbsp;some&nbsp;confirmation&nbsp;here:&nbsp;  
&nbsp;&nbsp;  
&nbsp;1.The&nbsp;map&nbsp;is&nbsp;“null”&nbsp;only&nbsp;appears&nbsp;when&nbsp;doing&nbsp;a&nbsp;AjaxCall&nbsp;for&nbsp;the&nbsp;first&nbsp;time&nbsp;of&nbsp;the&nbsp;page,&nbsp;in&nbsp;other&nbsp;words,&nbsp;when&nbsp;the&nbsp;view&nbsp;is&nbsp;starting&nbsp;loading,&nbsp;an&nbsp;Ajax&nbsp;call&nbsp;is&nbsp;called&nbsp;to&nbsp;pass&nbsp;the&nbsp;device&nbsp;coordinate&nbsp;to&nbsp;the&nbsp;server&nbsp;side&nbsp;“action&nbsp;of&nbsp;the&nbsp;controller”.&nbsp;&nbsp;  
&nbsp;2.There&nbsp;is&nbsp;a&nbsp;flag&nbsp;on&nbsp;client&nbsp;side,&nbsp;which&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;true&nbsp;if&nbsp;the&nbsp;“OnMapCreated”&nbsp;event&nbsp;is&nbsp;triggered.&nbsp;If&nbsp;it’s&nbsp;true,&nbsp;the&nbsp;AjaxCall&nbsp;mentioned&nbsp;in&nbsp;#1&nbsp;will&nbsp;be&nbsp;called.&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Please&nbsp;take&nbsp;a&nbsp;check&nbsp;and&nbsp;anything&nbsp;wrong&nbsp;I&nbsp;understood&nbsp;here;&nbsp;please&nbsp;feel&nbsp;free&nbsp;to&nbsp;correct&nbsp;me.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Johnny&nbsp;

---

<div class="post-metadata">

**Author:** ![Sindre](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/sindre/32/24981_2.png) [@Sindre](https://community.thinkgeo.com/u/Sindre)\
**Post date:** [February 22, 2013, 5:35am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/11 "2013-02-22T05:35:33Z")

</div>

In&nbsp;my&nbsp;situation,&nbsp;it&nbsp;DOES&nbsp;NOT&nbsp;happen&nbsp;on&nbsp;initial&nbsp;page&nbsp;load.&nbsp;I&nbsp;have&nbsp;a&nbsp;javascript&nbsp;timer&nbsp;which&nbsp;calls&nbsp;an&nbsp;MVC&nbsp;controller&nbsp;method&nbsp;periodically&nbsp;and&nbsp;makes&nbsp;some&nbsp;modifications&nbsp;to&nbsp;the&nbsp;map,&nbsp;then&nbsp;does&nbsp;a&nbsp;"layer.redraw()".&nbsp;  
  
  
  
It&nbsp;can&nbsp;work&nbsp;fine&nbsp;for&nbsp;several&nbsp;minutes,&nbsp;then&nbsp;suddenly&nbsp;the&nbsp;"map"&nbsp;parameter&nbsp;is&nbsp;null.

I&nbsp;can&nbsp;also&nbsp;add&nbsp;that&nbsp;when&nbsp;this&nbsp;happens,&nbsp;the&nbsp;following&nbsp;error&nbsp;is&nbsp;displayed&nbsp;in&nbsp;the&nbsp;Chrome&nbsp;console&nbsp;window:

`Resource interpreted as Image but transferred with MIME type text/plain: "localhost/tile_GeoResource.axd?OVERLAYID=DynamicOverlay&FORMAT=image…4693191.6103125,-1255443.678125,5006277.678125&WIDTH=256&HEIGHT=256&ZOOM=7". extension_GeoResource.axd:515OpenLayers.Tile.Image.OpenLayers.Class.renderTile extension_GeoResource.axd:515OpenLayers.Tile.Image.OpenLayers.Class.draw opl_GeoResource.axd:479OpenLayers.Layer.Grid.OpenLayers.Class.spiralTileLoad opl_GeoResource.axd:467OpenLayers.Layer.Grid.OpenLayers.Class.initGriddedTiles opl_GeoResource.axd:466OpenLayers.Layer.Grid.OpenLayers.Class.moveTo opl_GeoResource.axd:460OpenLayers.Layer.OpenLayers.Class.redraw opl_GeoResource.axd:195OpenLayers.Layer.HTTPRequest.OpenLayers.Class.redraw opl_GeoResource.axd:456OpenLayers.Layer.OpenLayers.Class.setVisibility opl_GeoResource.axd:197(anonymous function) VesselTracker.module.js:326OpenLayers.Events.OpenLayers.Class.triggerEvent opl_GeoResource.axd:137OpenLayers.Map.OpenLayers.Class.pan opl_GeoResource.axd:168OpenLayers.Control.DragPan.OpenLayers.Class.panMapDone opl_GeoResource.axd:1117OpenLayers.Handler.OpenLayers.Class.callback opl_GeoResource.axd:633OpenLayers.Handler.Drag.OpenLayers.Class.dragend opl_GeoResource.axd:638OpenLayers.Handler.Drag.OpenLayers.Class.mouseup opl_GeoResource.axd:639OpenLayers.Events.OpenLayers.Class.triggerEvent opl_GeoResource.axd:137OpenLayers.Events.OpenLayers.Class.handleBrowserEvent opl_GeoResource.axd:138(anonymous function)`

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [February 23, 2013, 5:51pm UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/12 "2013-02-23T17:51:39Z")

</div>

Hi&nbsp;Johnny,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;You&nbsp;are&nbsp;correct&nbsp;and&nbsp;yes&nbsp;I&nbsp;do&nbsp;have&nbsp;the&nbsp;same&nbsp;kind&nbsp;of&nbsp;message&nbsp;than&nbsp;the&nbsp;&nbsp;one&nbsp;Sindre&nbsp;is&nbsp;getting.&nbsp;&nbsp;In&nbsp;my&nbsp;case&nbsp;it&nbsp;is&nbsp;first&nbsp;call&nbsp;but&nbsp;I&nbsp;think&nbsp;it&nbsp;could&nbsp;occur&nbsp;latter&nbsp;as&nbsp;well.&nbsp;&nbsp;I&nbsp;think&nbsp;that&nbsp;I&nbsp;have&nbsp;the&nbsp;issue&nbsp;time&nbsp;to&nbsp;time.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Jm

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [February 25, 2013, 6:44am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/13 "2013-02-25T06:44:41Z")

</div>

Hi&nbsp;Guys,

Thank&nbsp;you&nbsp;very&nbsp;much&nbsp;for&nbsp;detailed&nbsp;description,&nbsp;I&nbsp;made&nbsp;a&nbsp;demo&nbsp;attached&nbsp;following&nbsp;Sindre's&nbsp;description&nbsp;using&nbsp;both&nbsp;LayerOverlay&nbsp;and&nbsp;MarkerOverlay,&nbsp;and&nbsp;start&nbsp;the&nbsp;timer&nbsp;for&nbsp;minutes,&nbsp;but&nbsp;seems&nbsp;like&nbsp;things&nbsp;go&nbsp;well.&nbsp;Can&nbsp;you&nbsp;make&nbsp;some&nbsp;changes&nbsp;based&nbsp;on&nbsp;it&nbsp;to&nbsp;reproduce&nbsp;the&nbsp;problem?

Thanks,  
  
Johnny

[MvcMapNullException.zip](https://community.thinkgeo.com/uploads/default/original/2X/4/4e823b77138906b53a558ff9427563382094b04b.zip) (556 KB)

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [February 28, 2013, 4:16am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/14 "2013-02-28T04:16:32Z")

</div>

Hi&nbsp;Johnny,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;got&nbsp;and&nbsp;try&nbsp;your&nbsp;sample&nbsp;application&nbsp;and&nbsp;it&nbsp;is&nbsp;working&nbsp;fine.&nbsp;&nbsp;However,&nbsp;we&nbsp;have&nbsp;to&nbsp;compare&nbsp;apple&nbsp;and&nbsp;apple,&nbsp;&nbsp;in&nbsp;my&nbsp;case&nbsp;the&nbsp;mvc&nbsp;razor&nbsp;map&nbsp;control&nbsp;is&nbsp;way&nbsp;more&nbsp;complex,&nbsp;eg:&nbsp;markers,&nbsp;overlays,&nbsp;layers,…&nbsp;&nbsp;And&nbsp;not&nbsp;only&nbsp;one&nbsp;many…&nbsp;&nbsp;Now&nbsp;the&nbsp;issue&nbsp;with&nbsp;map&nbsp;being&nbsp;null&nbsp;when&nbsp;using&nbsp;Ajax&nbsp;to&nbsp;talk&nbsp;with&nbsp;the&nbsp;controller&nbsp;is&nbsp;happening&nbsp;a&nbsp;lot.&nbsp;&nbsp;I&nbsp;would&nbsp;like&nbsp;to&nbsp;be&nbsp;able&nbsp;to&nbsp;provide&nbsp;you&nbsp;a&nbsp;good&nbsp;example&nbsp;but&nbsp;all&nbsp;of&nbsp;my&nbsp;applications&nbsp;involve&nbsp;background&nbsp;data&nbsp;base&nbsp;and&nbsp;other&nbsp;local&nbsp;services.&nbsp;&nbsp;If&nbsp;you&nbsp;could&nbsp;tell&nbsp;us&nbsp;what&nbsp;to&nbsp;look&nbsp;for&nbsp;on&nbsp;the&nbsp;JavaScript&nbsp;client&nbsp;side&nbsp;then&nbsp;we&nbsp;could&nbsp;check&nbsp;for&nbsp;map&nbsp;null&nbsp;or&nbsp;something&nbsp;before&nbsp;using&nbsp;the&nbsp;Ajax&nbsp;call?&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;in&nbsp;advance.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Jm

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [March 1, 2013, 4:26am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/15 "2013-03-01T04:26:22Z")

</div>

&nbsp;Hi&nbsp;Guys,

&nbsp;  
Thanks&nbsp;for&nbsp;all&nbsp;your&nbsp;help.&nbsp;Here&nbsp;are&nbsp;some&nbsp;partial&nbsp;code&nbsp;which&nbsp;can&nbsp;help&nbsp;us&nbsp;for&nbsp;debug:  
&nbsp;  
In&nbsp;the&nbsp;packaged&nbsp;function&nbsp;"ajaxCall"&nbsp;in&nbsp;func\_GeoResource.axd&nbsp;in&nbsp;runtime,&nbsp;it&nbsp;would&nbsp;be&nbsp;like&nbsp;this:  
`    ajaxCall: function (url, params, callback) {        var wRequest = new Sys.Net.WebRequest();        wRequest.set_url(url);        wRequest.set_httpVerb('POST');        var mapParser = this.getMapParser();        var param = ' __#' + mapParser.pageName + "|__ #";        for (var item in params) {            param = param + item + ":" + params[item] + '^';        }        wRequest.set_body(param);        wRequest.add_completed(callback);        wRequest.invoke();    },`  
&nbsp;  
&nbsp;  
You&nbsp;can&nbsp;see&nbsp;the&nbsp;mapParser.pageName&nbsp;property&nbsp;which&nbsp;actually&nbsp;is&nbsp;the&nbsp;session&nbsp;key&nbsp;as&nbsp;map&nbsp;and&nbsp;it&nbsp;was&nbsp;stored&nbsp;at&nbsp;the&nbsp;first&nbsp;loading.&nbsp;So,&nbsp;I&nbsp;guess&nbsp;the&nbsp;null&nbsp;map&nbsp;might&nbsp;be&nbsp;caused&nbsp;by&nbsp;an&nbsp;empty&nbsp;pageName&nbsp;or&nbsp;the&nbsp;session&nbsp;map&nbsp;is&nbsp;missing&nbsp;on&nbsp;the&nbsp;server.&nbsp;  
&nbsp;  
Besides,&nbsp;we&nbsp;can&nbsp;recreate&nbsp;it&nbsp;but&nbsp;only&nbsp;when&nbsp;the&nbsp;session&nbsp;is&nbsp;time&nbsp;out.&nbsp;so,&nbsp;please&nbsp;confirm&nbsp;the&nbsp;null&nbsp;map&nbsp;is&nbsp;not&nbsp;caused&nbsp;by&nbsp;session&nbsp;time&nbsp;out.&nbsp;Actually,&nbsp;in&nbsp;our&nbsp;Web/Mvc&nbsp;edition,&nbsp;the&nbsp;session&nbsp;should&nbsp;not&nbsp;be&nbsp;timeout&nbsp;as&nbsp;we&nbsp;do&nbsp;a&nbsp;request&nbsp;to&nbsp;server&nbsp;every&nbsp;15&nbsp;minutes&nbsp;to&nbsp;keep&nbsp;session&nbsp;alive.&nbsp;You&nbsp;can&nbsp;find&nbsp;the&nbsp;method&nbsp;named&nbsp;“keepsession”&nbsp;in&nbsp;“helper\_GeoResouce.axd”&nbsp;file.&nbsp;If&nbsp;the&nbsp;reason&nbsp;is&nbsp;15&nbsp;minutes&nbsp;too&nbsp;long,&nbsp;you&nbsp;can&nbsp;add&nbsp;an&nbsp;extra&nbsp;method&nbsp;to&nbsp;reduce&nbsp;the&nbsp;time.&nbsp;Like&nbsp;below&nbsp;is&nbsp;every&nbsp;1&nbsp;minute:  
&nbsp;  
`customKeepSession();function customKeepSession() {    window.setInterval(function A() {        OpenLayers.Request.issue({ url: 'session_GeoResource.axd' });    }, 60000);}`  
&nbsp;  
If&nbsp;possible,&nbsp;please&nbsp;have&nbsp;a&nbsp;try.  
Hope&nbsp;you&nbsp;are&nbsp;lucky&nbsp;and&nbsp;look&nbsp;forward&nbsp;to&nbsp;your&nbsp;further&nbsp;information.  
&nbsp;  
Thanks  
Johnny

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [March 23, 2013, 11:54am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/16 "2013-03-23T11:54:40Z")

</div>

Hi,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Was&nbsp;very&nbsp;busy!!!&nbsp;but&nbsp;I&nbsp;am&nbsp;back&nbsp;now!&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;issue&nbsp;is&nbsp;still&nbsp;alive&nbsp;and&nbsp;I&nbsp;do&nbsp;update&nbsp;the&nbsp;DLLs&nbsp;every&nbsp;day&nbsp;using&nbsp;the&nbsp;daily&nbsp;build.&nbsp;&nbsp;&nbsp;I&nbsp;can&nbsp;tell&nbsp;for&nbsp;sure&nbsp;that&nbsp;in&nbsp;my&nbsp;case&nbsp;there&nbsp;is&nbsp;no&nbsp;session&nbsp;time&nbsp;out&nbsp;because&nbsp;the&nbsp;issue&nbsp;arise&nbsp;when&nbsp;I&nbsp;load&nbsp;the&nbsp;application&nbsp;first&nbsp;time…&nbsp;&nbsp;However,&nbsp;I&nbsp;have&nbsp;an&nbsp;application&nbsp;with&nbsp;3&nbsp;MVC&nbsp;map&nbsp;control&nbsp;inside&nbsp;the&nbsp;same&nbsp;page&nbsp;and&nbsp;the&nbsp;issue&nbsp;occur&nbsp;for&nbsp;the&nbsp;first&nbsp;map…&nbsp;&nbsp;then&nbsp;the&nbsp;2&nbsp;other&nbsp;maps&nbsp;are&nbsp;just&nbsp;working&nbsp;OK…&nbsp;&nbsp;the&nbsp;other&nbsp;thing&nbsp;is&nbsp;that&nbsp;when&nbsp;I&nbsp;refresh&nbsp;the&nbsp;page&nbsp;then&nbsp;all&nbsp;maps&nbsp;are&nbsp;correct…&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;What&nbsp;is&nbsp;happening&nbsp;when&nbsp;the&nbsp;web&nbsp;page&nbsp;load&nbsp;first&nbsp;time???&nbsp;&nbsp;&nbsp;why&nbsp;is&nbsp;the&nbsp;map&nbsp;object&nbsp;return&nbsp;to&nbsp;the&nbsp;server&nbsp;side&nbsp;by&nbsp;the&nbsp;Ajax&nbsp;call&nbsp;empty???&nbsp;  
&nbsp;&nbsp;  
&nbsp;jm.

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [March 24, 2013, 10:31pm UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/17 "2013-03-24T22:31:28Z")

</div>

Hi&nbsp;Jean-marie,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;guess&nbsp;we&nbsp;are&nbsp;getting&nbsp;close&nbsp;to&nbsp;each&nbsp;other.&nbsp;Could&nbsp;you&nbsp;let&nbsp;me&nbsp;know&nbsp;how&nbsp;you&nbsp;call&nbsp;the&nbsp;client&nbsp;AjaxCall?&nbsp;Can&nbsp;you&nbsp;show&nbsp;this&nbsp;scripts&nbsp;and&nbsp;the&nbsp;corresponding&nbsp;Action&nbsp;code&nbsp;here?&nbsp;I&nbsp;just&nbsp;tried&nbsp;3&nbsp;maps&nbsp;in&nbsp;one&nbsp;view&nbsp;page,&nbsp;it&nbsp;works&nbsp;fine&nbsp;for&nbsp;me,&nbsp;maybe&nbsp;I&nbsp;didn’t&nbsp;put&nbsp;the&nbsp;AjaxCall&nbsp;to&nbsp;the&nbsp;position&nbsp;where&nbsp;you&nbsp;are&nbsp;using.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Johnny

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [March 26, 2013, 12:57pm UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/18 "2013-03-26T12:57:50Z")

</div>

Please&nbsp;let&nbsp;me&nbsp;know&nbsp;when&nbsp;you&nbsp;will&nbsp;have&nbsp;an&nbsp;answer&nbsp;for&nbsp;me.&nbsp;&nbsp;I&nbsp;have&nbsp;uploaded&nbsp;the&nbsp;sample&nbsp;application&nbsp;on&nbsp;your&nbsp;FTP&nbsp;yesterday&nbsp;afternoon.&nbsp;  
&nbsp;&nbsp;  
&nbsp;thanks

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [March 27, 2013, 5:28am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/19 "2013-03-27T05:28:57Z")

</div>

Hi&nbsp;Jean-marie,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;providing&nbsp;the&nbsp;further&nbsp;information,&nbsp;we&nbsp;have&nbsp;created&nbsp;a&nbsp;ticket&nbsp;(9684)&nbsp;for&nbsp;you,&nbsp;please&nbsp;check&nbsp;the&nbsp;anwser&nbsp;there.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Johnny

---

<div class="post-metadata">

**Author:** ![Jean-marie](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@Jean-marie](https://community.thinkgeo.com/u/Jean-marie)\
**Post date:** [April 3, 2013, 9:18am UTC](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008/20 "2013-04-03T09:18:30Z")

</div>

I&nbsp;found&nbsp;what&nbsp;seems&nbsp;to&nbsp;be&nbsp;the&nbsp;issue&nbsp;with&nbsp;the&nbsp;MAP&nbsp;being&nbsp;null&nbsp;!!!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;was&nbsp;able&nbsp;to&nbsp;observe&nbsp;that&nbsp;for&nbsp;whatever&nbsp;reason&nbsp;the&nbsp;thinkgeo&nbsp;or&nbsp;openlayers&nbsp;code&nbsp;try&nbsp;to&nbsp;use&nbsp;an&nbsp;object&nbsp;that&nbsp;has&nbsp;been&nbsp;saved&nbsp;previously&nbsp;inside&nbsp;the&nbsp;browser&nbsp;cache…&nbsp;&nbsp;clearing&nbsp;the&nbsp;browser&nbsp;cache&nbsp;&nbsp;&nbsp;solve&nbsp;the&nbsp;issue&nbsp;instantly!&nbsp;  
&nbsp;&nbsp;  
&nbsp;jm

[Next page](https://community.thinkgeo.com/t/map-is-sometimes-null-in-controller-action-method/4008.md?page=2)
