我試着去建立使用WCF和.NET 4的API,但是當我扔WebProtocolException,它不顯示它應該像一個不錯的錯誤信息,而不是它是治療它像一個未處理的異常。WCF .NET 4.0的治療WebProtocolException作爲未處理的異常
我正在使用WebServiceHost2Factory。
是否有其他人使用過.net 4的WebProtocolException?
我的電話的下面是一個例子
throw new WebProtocolException(System.Net.HttpStatusCode.BadRequest, "The DateFrom parameter is invalid",
new Error()
{
Code = 6002,
Message = "Please ensure your dates are in the following format: yyyy/MM/dd hh:mm:ss"
},
null, null);