【发布时间】:2013-02-20 06:53:41
【问题描述】:
我抛出未处理的 DataServiceExceptions(它们由 WCF 自动处理)以返回未授权访问的状态代码等。如何防止 Visual Studio 中断这些未处理的异常?
if (!System.Web.Security.Roles.IsUserInRole("Users"))
{
throw new DataServiceException((int)HttpStatusCode.Unauthorized, "You do not have access to this resource.");
}
【问题讨论】:
-
“我使用未处理的 DataServiceExceptions”、“它们由 WCF 自动处理”、“在这些未处理的异常中中断”。所以基本上你正在处理它吗?你在 catch 声明中抓住它了吗?还是直接扔?
-
请更新您的代码...
-
我只是抛出新的 DataServiceException(401, "Error...")。 WCF 自动解包并将格式化的错误消息发送到客户端,但 Visual Studio 仍然在我的代码行中断。根本没有try..catch。
标签: asp.net wcf iis visual-studio-debugging