I have a set of WCF services that I used with an ASP.NET MVC application. These utility operations throw a FaultException when the server has identified a problem with what the client has sent. For instance:
if(string.IsNullOrEmpty(request.Name)) throw new FaultException<ValidationDictionary>(new ValidationDictionary());
This works fine in my ASP.NET application
catch(FaultException<ValidationDictionary> fault) {
However, with Silverlight, all this fails. The server returns a 500 status code with an error (as expected), but for Silverlight it looks like a duff response.
The following MS article points out (ugly) work for this: http://msdn.microsoft.com/en-us/library/ee844556%28v=vs.95%29.aspx This workaround causes the service to send 200 status codes, even if a FaultException exists, so the Silverlight client can get them. But this will ruin the "normal" clients of my service (my ASP.NET application, other users in the wild).
However, the service point is the separation of your customers. I still want my services to return 500 status codes so that my ASP.NET application detects FaultExceptions errors and processes them. But I also want Silverlight to be able to handle them.
Has anyone come across this before?
James source share