Skip to main content
 首页 » 编程设计

c#之Silverlight 4 是否需要 SilverlightFaultBehavior 类

2024年02月23日15zhenyulu

MSDN说

Silverlight version 4 enables support for the Windows Communication Foundation (WCF) SOAP fault programming model, which allows the service to communicate error conditions to the client. In previous versions of Silverlight, if an error occurred on the service, it would register as an HTTP 500 response code and details about the error would not be accessible to the Silverlight client.

然而,许多其他位置建议仍将其用于 Silverlight 4 客户端,并且上述内容对于 Silverlight 4 的操作似乎相当含糊。我想知道是否有人可以确认应该使用什么方法来处理 Silverlight 4 上的 WCF 错误.

请您参考如下方法:

是的,如果您想在 Silverlight 4 客户端中捕获错误,您将需要使用自定义 WCF 行为,在服务引发错误时将 HTTP 状态代码从 500 更改为 200。

参见:http://msdn.microsoft.com/en-us/library/ee844556(v=vs.95).aspx