Asp.net Ajax error handling, how to show full exception
how can i show the full blown .net exception that may occur on an ajax enabled page. i want it to show like it would if the page wasnt using ajax. This for my QA environment for which i dont have the option to temporarily disable update panel. Also i dont want javascript t开发者_如何学JAVAo handle it as our QA testers are wanting to see the usual full blown asp.net exception.
Most likely there is no way to show an exception on classic yellow ASP.NET error page after ajax call. But you can send required information via AsyncPostBackErrorMessage and then replace body of the aspx page by some javascript (and jquery):
$(document).ready(function () {
var manager = Sys.WebForms.PageRequestManager.getInstance();
manager.add_endRequest(EndRequestHandler);
});
function EndRequestHandler(sender, args) {
if (args.get_error() != undefined) {
var errorMessage = args.get_error().message;
args.set_errorHandled(true);
$('body').replaceWith(errorMessage);
}
}
In ScriptManager.AsyncPostBackError you can try to render some html that may emulate yellow screen of death. There is an inspiration how to do that on this page: http://www.codeproject.com/KB/aspnet/ASPNETExceptionHandling.aspx.
精彩评论