Reputation: 557
I am using WCF REST Service for my silverlight application. When I throw a webfault exception with error code 500. The silver light displays the error message:'Error:404 File not found'. I did some research and found that it is the problem with browser i.e. the browser stack can only pass two response codes, 200 and 404 to any plugin here in my case its silverlight. That means when ever there is a webfault exception at the server side the SL will only display the message 'File not found'. I want the error message to be passed to the client. One such solution is to pass the response code 200 and send the error message to the client attached to the return object of some similar logic like this. I want know if there is anything else that is possible so that I dont have to change my class structure. Also I am returning JSON objects from the server. I basically need to SilverLight to get response codes other than 200 and 400 series.
Upvotes: 1
Views: 343
Reputation: 180917
Microsoft added a separate HTTP stack for your purpose when they released Silverlight 3.
Specifying the HTTP stack is easy. You simply call the WebRequest.RegisterPrefix method, passing the ClientHttp object to specify client HTTP handling or a BrowserHttp object to specify browser HTTP handling. You do this before you make any web requests.
The new stack has less limitations than the old one in that it can handle more HTTP methods and it can handle any HTTP return code. See the chart in the linked blog post for a more extensive comparison.
Upvotes: 1