Im trying to build an API using WCF and .Net 4, however when I throw the WebProtocolException, it is not displaying a nice error message like it should, instead it is treating it like an unhandled exception.
I am using the WebServiceHost2Factory.
Has anyone else used WebProtocolException with .net 4?
An example of my call is below
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);