50

Since I installed Visual Studio 2010 from scratch about 2 months ago, it behaves slightly different when debugging JavaScript code being run in IE.

  • When I set a breakpoint, it opens a duplicate of the view with the term "[dynamic]" in the header and marks the breakpoint in there.
  • When a JavaScript error happens during execution, it does the same before it marks the line of code that threw the error.
  • This "dynamic" view is editable but edits have no effect - they are not saved to the file.

I find this behavior pretty uncomfortable. Everytime I notice an error in the code during debugging, I happen to fix it in the dynamic view. I hit save. VS does not complain. Next I refresh the page in IE, and - bang - the changes are lost, it loads the untouched old version again.

I haven't been able to find out how I can turn these views off. Before I re-installed Visual Studio it did not do that. It would only create "dynamic" views for script found in inline script tags in HTML files.

chiccodoro
  • 14,407
  • 19
  • 87
  • 130
  • I would also love to find an answer to this. In my case, I narrowed down the problem to using "add as link" when I add existing files to my project. If I add existing files normally, not using add-as-link, and let VS make its own copy, then I can edit files in debug mode, without problems. If I use "add as link", then debugging brings up the "[dynamic]" file instead, and I can't edit. Any chance this is related to your issue as well? Simply not using "add as link" is not an acceptable solution, in my opinion. – stay Feb 19 '13 at 23:41
  • @stay, I don't have any external JS files in my Visual Studio solution. They are all part of the projects. – chiccodoro Feb 20 '13 at 13:17

7 Answers7

41

Try this IE > Internet Options > Settings (under browsing history) > Check for new version of stored pages : Every time I visit the webpage.

This works for me in IE10.

enter image description here

Other option is to open Developer tools and select cache option Always Refresh from Server as show in the image below

enter image description here

Dhana Krishnasamy
  • 2,126
  • 17
  • 36
  • 1
    @Zain I have added the screenshot. If you still cant find it, it could be that your system admin could have removed the option (assuming its a corporate box) – Dhana Krishnasamy Mar 02 '14 at 17:30
  • 1
    THANK YOU for this. This behavior has been driving me nuts for months! Was able to work around it until this morning which forced me to search for an answer and voila, fixed. Wish I'd searched earlier. :S – Hardycore Jan 21 '15 at 15:44
16

Try hitting CTRL+F5 on the web page. That did the trick for me.

The problem was that I had opened other IE windows from a previous debugging session, so the dynamic javascript files were still cached.

Zain Rizvi
  • 23,586
  • 22
  • 91
  • 133
4

For Google Chrome:

  • Open developer tools(F12)
  • Open Network Conditions Tool
  • Select Disable Cache

enter image description here

mkb
  • 1,106
  • 1
  • 18
  • 21
  • 2
    This is nice, but temporary as when you restart your application, you need to do this process all over again – Thundter Jun 26 '18 at 08:15
3

Having developer tools open - F12 - should also cause the cache files for the page to be cleared on each refresh.

Benjineer
  • 1,530
  • 18
  • 22
3

Changing the encoding of the JS file in question, from a Windows codepage to UTF-8, fixes this for me.

Narrowing it down, it appears that OEM Extended ASCII characters in the file (e.g. ALT-254 which I use for a bullet) trigger the problem with the Windows codepage files.

(Visual Studio 2013 Update 5, IE11)

Martin Connell
  • 175
  • 2
  • 6
1

I had the same problem of not being able to hit a break point in new code. And breakpoints on old code in the same page will bring up the [dynamic] version. The edited page is not reloaded. This just started for me a week ago in both VS2012 and VS2013. Using refresh page and/or Ctl-F5 did not work for me. BUT, reading this thread pointed me to using F12 to open Developer tools. Leaving that window open, while hitting refresh does the trick. Thanks guys.

MartinDuo
  • 663
  • 12
  • 25
  • 2
    This "feature" of VS is still present in 2022! Looking for a real JS debugger that doesn't cache! (why would MS even cache ANYTHING ?!?! Trying to drive developers insane) – MC9000 Jul 08 '22 at 19:22
  • Agree, I'm unable to turn this "feature" off in Visual Studio 2022 ... there is NO point where I would want to work with "cached" anything while I'm running the debugger ... it makes zero sense to default to cached dynamic JS in VS, no sense. I'm going to guess one developer somewhere thought it would be useful ignoring the 99% that find it just gets in the way. – Rob Ainscough Sep 28 '22 at 21:46
  • I had exactly the same problem as you folks (with VS 2022). I upgraded to 17.5.0 using the standard VS installer and the problem seems to have gone away. – Peter Schaeffer Feb 22 '23 at 18:44
0

1) Run the page Without Debugging (Debug-->Start Without Debugging)

2) While the web page is open in Internet Explorer, press Ctrl-F5 so that the IE cache is cleared. Ensure IE has the focus.

3) Close IE and re-run the page with Debugging (Debug-->Start Debugging).

This fixed the issue for me.

Ray
  • 4,679
  • 10
  • 46
  • 92