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
WebFaultExceptionis 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 regardingWebFaultExceptionusage.