Sunday, March 6, 2011

Javascript Error thrown by AjaxToolKit in .NET only on some machines

We have a button that saves asynchronously using AjaxToolKit/C#/.NET. I'm getting this in my Error Console:

Error: [Exception... "'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException:
An unknown error occurred while processing the request on the server. The status code returned from the server was: 500' when calling method:
[nsIDOMEventListener::handleEvent]"  nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)"  location: "<unknown>"  data: no]

The strangest thing about this is that it's only happening on some machines (but not all). Everyone in the office checked this out in FF 3.0.4 and IE 7, and the save works fine for most people. For the handful of people that it doesn't work for, it fails in both browsers.

Any ideas of where to start troubleshooting this?

  1. I'd say it was a server/code error, but it works for most people.
  2. I'd say it was a javascript error, but we're all using the same browser.
  3. I might even say it was an OS difference, but it happens to both XP and Vista users.
  4. User Permissions are the same for all of us

The application was working correctly until this weekend's update, where we updated a UserControl on the page. If I remove that control, the save works fine on all computers. When I add the control, we have the above situation where it fails on random computers.

Answer

Unfortunately, this was hard to track down due to the mysteriousness of how AjaxToolKit returns errors. The real culprit was that there was HTML in some of our fields in the UserControl. We added ValidateRequest="false" to the top of our page, and our problems disappeared.

The way we ultimately found the problem was to remove the UpdatePanel from around our Save button.

Sorry I didn't think of this sooner, because it was pretty straightforward from there. I'm giving Michael the accepted answer for his hard work and exhaustive troubleshooting list.

From stackoverflow
  • Things to check:

    1. Reboot (oldie but goodie, and doesn't always go without saying)
    2. OS version (you did this)
    3. Web browser (you did this)
    4. Web browser settings (you covered this by trying multiple browsers)
    5. Network connectivity and Hosts file rules
    6. User permissions (you covered this)
    7. Application permissions (you covered this)
    8. OS locale settings (control panel: Regional and Language Options)
    9. Try and capture more information.

    In this situation, I'd probably download a virgin browser to try to rule out browser settings. I'd throw Google Chrome onto a known good machine and a known bad machine to see what happens. If it works in both cases, then I'd look further at browser settings. I know that this isn't likely the case since it fails in both FF and IE, but IE this simple test could help provide a little more info nonetheless.

    It's a weird one. Since it affects both IE and FF, I'd also look at the connectivity angle, the hosts file, and permissions.

    Jon Smock : Good list - I'll edit my question to clarify some of these
    Jon Smock : Good call on the logs, searching now...
    Jon Smock : Can't find anything useful in IIS logs, Chrome didn't work on bad machine.
    Michael Haren : OK, since Chrome failed, we can ignore all the browser stuff, like cache, permissions, etc. What about the OS and network stuff? I assume you did a reboot, too...?
    Michael Haren : (Note that Chrome has to work on a good machine to be a valid test on the bad machine)
  • It is not the error of Ajax, Somewhere your code has error.remove Ajax and then check,u will come to know What is exact error.

    Ajit

0 comments:

Post a Comment