JavaScript exception but only with breakpoint active while stepping thru code

Viewed 49

I'm having a strange issue with some old JS code in an ASP.NET web application (circa 2006-2008 code base and updated to .NET 4.8). I deployed to a test server where the web app will not populate a dropdown control. Our production version does populate the dropdown correctly. The code is identical between the two servers (test and production) so it must be some environmental settings or IIS setting or maybe even a .NET 4.8 configuration.

On my development PC (local running IIS Express), if I do NOT place a breakpoint the code works as it should and the dropdown is populated correctly.

I've checked the web.config to make sure all is good for each environment, everything appears to be set correctly.

I've looked at IIS on both test and production servers and I don't see anything different.

I tried remote debugging on the test server but that didn't reveal anything different than running debug on local source.

When debugging with my local dev PC where I step thru the code I get an exception in the JS code (be aware the is JS in ASP.NET app so Visual Studio uses [Dynamic] in the tab). I'm not going to go into details of why JS code is being used when ASP.NET code behind could accomplish the same functionality more cleanly, but it's an old web app and clearly had many developer footprints where some seemed to be more JS developers while others more ASP.NET developers. Some of the code is really old and really bad, loading ActiveX controls on the fly etc.

That suggests to me that this might be some type of event timing issue. Unfortunately the exception provides no specific details on what the error is.

Any thoughts on how to proceed or get a more meaningful exception message out of the JS code?

1 Answers

Try inserting console log statements into the JavaScript code and running the code on the test server.

console.log("Site has loaded");
var value = document.getElementById(id).value;
console.log(value);

Then read the logs and errors from the debug browser's Developer Tools (press F12 and select the Console tab). Chrome dev tools

Some things to try:

  • Double check the system references and their version numbers that they are the same.
  • Check firewall settings that they are not blocking the loading of a web reference.
Related