Thursday, March 29, 2007

Ajax extensions services always report “There was an error processing the request.”

I have been puzzled by the following for quite a while.

I use Microsoft Ajax extensions 1.0 to query web services which may raise exceptions. In my development environment, I would always get a nice localized error message but on the production server, the same code would produce a generic “There was an error processing the request”.

After having spent enough time stepping through my code with a debugger, I have decided to look at the Ajax extensions code and I have found the following piece of code in WriteExceptionJsonString of RestHandler.cs.

if (context.IsCustomErrorEnabled)
writer.Write(JavaScriptSerializer.SerializeInternal(new WebServiceError(

AtlasWeb.WebService_Error, String.Empty, String.Empty)));
writer.Write(JavaScriptSerializer.SerializeInternal(new WebServiceError(

ex.Message, ex.StackTrace, ex.GetType().FullName)));

Where WebService_Error is a resource which is valued “There was an error processing the request.”

This means that if you have enabled custom errors in your web.config on your production environment like I did, your Ajax calls will always report a generic error.

Why have the Microsoft people introduced such a restriction is a mystery to me.


Anonymous said...

Hello Jacques, I've tried to reach you by email, but don't have an up to date address. I trust all is well? I would be interested to catch up if you're in central London.
Max Bleyleben, Kennet Partners

Anonymous said...

Thanks for sharing this! I had been looking for a few hours and a link off of Google showed this.


Anonymous said...

I have posted a related blog, with an easy workaround to this issue in case you are interested. Thanks for the info in your post.

Unknown said...

It was helpfull!

Thank you!