Getting Exception Details from ASP.NET PageMethods on the Client SIde

穿精又带淫゛_ 提交于 2019-12-05 11:06:41

As far as I understand as long as you have

<customErrors mode="off" />

in your web.config, the message will be returned to client. Are you sure you have this setting ?

To display the message associated with error you need to have oassed the name of the function as the third parameter of the page method call : this function could be as simple as:

function onfailure( result )
{
   alert( result.get_message() );
}

That's what we have and it works OK

After you have set <customErrors mode="off" /> in the <system.web> section of the web.config, try these functions to get all of the exception details from the PageMethod's onfailure:

function onfailure(error) {                
    alert("Error: " + error.get_message() + "; " + 
        "Stack Trace: " + error.get_stackTrace() + "; " + 
        "Status Code: " + error.get_statusCode() + "; " + 
        "Exception Type: " + error.get_exceptionType() + "; " + 
        "Timed Out: " + error.get_timedOut());
}

I've found the error's status code to be far more helpful than the error message itself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!