WCF阻止调试器在DataServiceException中中断

时间:2013-02-20 06:53:42

标签: asp.net wcf iis visual-studio-debugging

我抛出未处理的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.");
        }

1 个答案:

答案 0 :(得分:0)

可以添加DebuggerNonUserCode属性

或者您可以告诉visual studio忽略异常类型,如:How to tell the debugger to ignore breaking on thrown exceptions?