I am using WCF REST Service (4.0) to expose JSON API ..but not getting my WebFaultException to work.
I have following in my method:
if (!int.TryParse(Id, out idValue))
{
throw new WebFaultException<string>(string.Format(WebExceptionMessages.NotIntegerAsParameter),
HttpStatusCode.BadRequest);
}
and when i try to call the service from fiddler i always receive the same error message:

I have been trying to search for a solution for some time now...please help.
The WebFaultException is working properly - the error message in Visual Studio is just telling you that it wasn't handled - that's the expected behavior. Visual Studio debugger will tell you it's unhandled since you didn't trap the error via try/catch. See related MSDN blog regarding WebFaultException usage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With