2012-04-27 73 views
3

我正在使用WCF REST服务(4.0)来公开JSON API ..但没有让我的WebFaultException正常工作。未在用户代码中处理WebFaultException

我已经按照我的方法:

 if (!int.TryParse(Id, out idValue)) 
     { 
      throw new WebFaultException<string>(string.Format(WebExceptionMessages.NotIntegerAsParameter), 
               HttpStatusCode.BadRequest); 
     } 

,当我尝试调用从小提琴手的服务,我总能收到同样的错误信息:

Error when debugged

我一直在努力现在搜索一段时间的解决方案...请帮助。

回答

1

WebFaultException工作正常 - 在Visual Studio中的错误消息只是告诉你它没有处理 - 这是预期的行为。 Visual Studio调试器会告诉你它没有处理,因为你没有通过try/catch捕获错误。请参阅related MSDN blog regarding WebFaultException usage

+0

这是...没有我觉得愚蠢。我检查出你提到的关系。在调试消息后,从来没有跑过代码... 现在我得到正确的回应:) – 2012-04-27 15:46:50

相关问题