Why couldn't I effectively refresh my aspx page in VS.NET when debugging? (clearing Javascript cache?)



I wrote a small aspx page that used RegisterStartupScript and StringBuilder to display a bunch of nodes on a windows live local map. This involved a lot of client-side JS script. I got the dreaded "Operation Aborted" error in IE7 which has been discussed to death on places like this: http://mapki.com/index.php?title=FAQs. I resolved that error with a bit of reading and tinkering. That solution appears below for anyone that needs it.

*However*, the fixed page would NOT work when I attempted to test it in VS.NET's internal browser(IE). It DID work when I uploaded it to my production server and fired up IE. VS.NET's browser uses IE internally, from what I understand. I'm guessing this was some kind of caching issue. It is troublesome to debug client-side code when you aren't sure whether you're looking at the "freshest" code or not. I am wondering why this happened and if there is a way to force VS.NET to show you exactly what you've been coding.

I am using the Visual Studio 2008 beta and love it (I don't think this is a beta issue.)

###
The solution to the issue I mentioned in p1. Copied from my work blog:
###
Avoiding "Operation Aborted" error with mapping and IE7

This comes up particularly often if you're using Page.ClientScript.RegisterStartupScript and Stringbuilder to inject client-side code to a webpage, especially in various mapping applications like "Windows Live Local" and Google maps.

The issue is that IE7 does not like you screwing around with the DOM before the page has completely rendered.

I don't have a complete understanding of every consideration, but I do know that the steps below worked for my app.

Steps:

1) Wrap your map rendering stuff as a function:

string myScript = "<script type='text/javascript'>function AddPin [function code here] function mapthis() { [call map rendering function and tack on a bunch of nodes using StringBuilder] "; Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myScript);

2) In the head of your webpage, define a function that will call the function embedded in the StringBuilder:

function OnLoadPage(){ mapthis(); }

3) Call OnLoadPage(); with the body tag:

4) Test by uploading to a server, NOT in VS.NET. VS.NET appears to cache and it won't be obvious when you've fixed your page.



.



Relevant Pages


Loading