[WebService(Namespace = "http://service.site.com/service/news")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[ScriptService]
public class NewsService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod]
public void DoPost(string title, string markdown, int categoryId)
{
if (!MembershipHelper.IsAtLeast(RoleName.Administrator))
throw new AuthenticationException();
}
}
There are several options, but none of them are specifically designed for such cases.
i.e:
- UnauthorizedAccessException: I / O
- AccessViolationException: memory stuff
- SecurityAccessDeniedException : Represents a security exception that is thrown when a security authorization request fails.
and etc.
Should I create my own exception type for this? What exception should occur when membership users do not have sufficient privileges to invoke a method?
source
share