2012-04-27 80 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

相關問題