Returning Error Details from AJAX-Enabled WCF Service

前端 未结 5 1258
鱼传尺愫
鱼传尺愫 2020-12-09 05:13

Short Version: Is there a/what is the suggested way to return error details to the client when an exception is thrown in an AJAX-Enabled WCF Service (aside

5条回答
  •  不知归路
    2020-12-09 05:44

    The only way I am able to get exception detail back is with

    
    

    I tried the suggested method with extending HttpWebBehavior but when it is used with enableWebScript like the following:

    
        
        
    
    

    The WCF call will return status code 202 without anything information. If the configuration turns into

    
            
            
        
    

    You will get the nicely formatted message back but you lose all the json formatting functionality as well as request parameter parsing from enableWebScript, which completely defeats the purpose of using enableWebScript

    I have attempted FaultContract as well but it appears to only work for Service References and not AJAX calls from JQuery.

    It would be nice to be able to override WebScriptEnablingBehavior or the service itself to provide custom error handling.

提交回复
热议问题