WCF .Net 4.0 is treating WebProtocolException as an unhandled exception
Posted
by Benjii
on Stack Overflow
See other posts from Stack Overflow
or by Benjii
Published on 2010-04-11T10:10:50Z
Indexed on
2010/04/11
10:13 UTC
Read the original article
Hit count: 345
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);
© Stack Overflow or respective owner