An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

So you came accross this error message. There might be different reasons for this error but in my case the reason is the validation of requests by default in one of my aspx pages. When I clicked a button, which was supposed to load a component on a page asynchronously, I got this error.

During my research on web I saw different solutions one of them proposed inserting below javascript code piece right after the ScriptManager on the page:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args) {
if (args.get_error() != undefined) {
args.set_errorHandled(true);
}
}

This will not do the job if you are trying to call a page method on button click. What this script does is just make the error disappear silently, without providing any fix and your click will not trigger the server side function you are trying to invoke.

In my case fix was pretty easy, setting ValidateRequest=”false” in the page directive of my aspx page.

Hope this helps someone.

Good luck,
Serdar.

Leave a Reply

Your email address will not be published. Required fields are marked *