- Hit custom html WebResource via browser.
- WebResource loads ClientGlobalContext.js.aspx via script tag:
<script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
- WebResource Displays link to CRM Entity. Navigate to CRM Entity via link.
- Click “back” button in browser to navigate back to the custom WebResource.
- Receive JS error:
GetClientContext is not defined
The first line is the load from the custom WebResource. The second line, is then the ClientGlobalContext.js.aspx, loads itself, but as an xhr, rather than a script. This loads the Xrm Context.
But when I look at the Network Tab when when I get the error: this is what I see:
The ClientGlobalContext.js.aspx is being loaded from cache. That’s a good thing normally, but it never actually executed the xhr request. Why Not? When I opened the cached document, it was actually the xhr that was cached:
So how do I prevent the xhr from getting cached over the top of the script version? Just append a query string to the end of the aspx page:
<script src="../../ClientGlobalContext.js.aspx?type=script" type="text/javascript"></script>That way, the files can get cached separately…