我有一個測試Web服務的診斷工具。獲取WebClient錯誤作爲字符串
我希望該工具在出現問題時進行報告,因此我已經部署了一個服務來解決合同問題以對其進行測試。
當我瀏覽到它,我得到一個網頁一個非常描述性信息,例如:
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension:
System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: DataContract for type XXX cannot be added to DataContractSet since type XXX with the same data contract name XXX in namespace XXX is already present and the contracts are not equivalent etc..
我要的是能夠調用:
myErrorMsg = WebClient.DownloadString("MyBadService.svc");
,並得到這個有用的錯誤消息作爲字符串,但我得到以下WebException:
The remote server returned an error: (500) Internal Server Error.
我怎樣才能得到相同的錯誤一團糟我在瀏覽器中收到的年齡以字符串的形式返回,沒有發生異常?
謝謝。
500錯誤意味着您的網站意外終止。 – Zenwalker