RIA服务中的异常处理
如您所知,建议使用带有标准 WCF 服务的FaultException 来处理异常,以隐藏异常详细信息。没关系,但我在使用 WCF Ria 服务时遇到问题。我想从域服务抛出异常,客户端将处理该异常。我想避免泄露异常的敏感信息,例如堆栈跟踪、方法名称等。如果是标准 WCF 服务,我会使用FaultException 异常,但在 Ria 服务中,它不起作用。无论我从域服务抛出哪种异常,客户端总是会收到 DomainOperationException。有什么方法可以从域服务向 silverlight 客户端抛出FaultException(不透露实际的异常详细信息)?例如,我有一个登录窗口。当用户点击登录按钮时,应该有几个验证失败,例如:
- 无效的用户名或密码
- 用户帐户被锁定
- 帐户未激活
- 等
我希望为每个可能发生的错误提供错误类型。客户端应该检查出了什么问题并相应地显示错误消息。我禁用了 customErrors 但没有帮助。任何帮助将不胜感激。 谢谢
As you know, it's recomended handle exceptions using FaultException with standard WCF service to hide exception details. That's fine but i'm having problem with WCF Ria service. I want to throw an exception from domain service and the client will handle that exception. I want to avoid disclosing exception's sensitive information such as stack trace, method names etc. If it were standard WCF service, I'd use FaultException exception, but in Ria service, it's not working. No matter what kind of Exception I throw from domain service, the client always gets DomainOperationException. Is there any way I can throw a FaultException to the silverlight client from domain service (to not disclose actual exception details)? For example, I have a login window. When the user hit's login button, there should be several validation failures, such as:
- Invalid username or password
- User account is locked
- The account is not activated
- etc
I want to have fault types for each error that may occure. The client should check what went wrong and display error message accordingly. I disabled customErrors but it didn't help. Any help would be appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是科林·布莱尔对我的问题的回答
它回答了我的问题和需求。谢谢科林。
Here's what Colin Blair answered to my question here
It answers my question and needs. Thanks Colin.
我读过有关在 Silverlight 中使用 WCF 错误的信息,但尚未尝试使用 WCF RIA。
http://mark. mymonster.nl/2011/02/10/make-use-of-wcf-faultcontracts-in-silverlight-clients/
I've read about using WCF faults in Silverlight, but haven't yet tried it with WCF RIA.
http://mark.mymonster.nl/2011/02/10/make-use-of-wcf-faultcontracts-in-silverlight-clients/
代码示例:
Code example: