Server-side exception handling in silverlight

I am using the WCF REST service for my silverlight application. When I throw a webfault exception with error code 500. Silver light displays an error message: "Error: 404 File not found." I did some research and found that this is a problem with the browser, i.e. The browser stack can only send two response codes: 200 and 404 for any plug-in here, in my case, its silverlight. This means that when a webfault exception occurs on the server, SL displays the message "File not found." I want the error message to be sent to the client. One such solution is to send a 200 response code and send an error message to the client attached to the returned object with some similar logic like this. I want to know if there is anything else that is possible, so I do not need to change the structure of the class. I also return JSON objects from the server. I mainly need SilverLight to get response codes other than 200 and 400.

+1
source share
1 answer

Microsoft added a separate HTTP stack for your purpose when they released Silverlight 3.

Specifying an HTTP stack is easy. You simply call the WebRequest.RegisterPrefix Method, which passes the ClientHttp object to indicate HTTP client processing, or the BrowserHttp object to specify the HTTP processing browser. You do this before you make any web requests.

The new stack has fewer restrictions than the old one, as it can handle more HTTP methods and can handle any HTTP return code. See Chart in a related blog post for a more extensive comparison.

+1
source

All Articles