我正在使用 WCF REST 服务 (4.0) 公开 JSON API ..但没有得到我的 WebFaultException
去工作。
我的方法中有以下内容:
if (!int.TryParse(Id, out idValue))
{
throw new WebFaultException<string>(string.Format(WebExceptionMessages.NotIntegerAsParameter),
HttpStatusCode.BadRequest);
}
当我尝试从 fiddler 调用服务时,我总是收到相同的错误消息:
我一直在尝试寻找解决方案一段时间......请帮助。
最佳答案
WebFaultException
工作正常 - Visual Studio 中的错误消息只是告诉您它没有被处理 - 这是预期的行为。 Visual Studio 调试器会告诉您它未处理,因为您没有通过 try/catch 捕获错误。见 related MSDN blog regarding WebFaultException
usage .
关于.net - 用户代码中未处理 WebFaultException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10350011/