[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();
// ...
}
}
利用可能なオプションがいくつかありますが、このような場合に特別に設計されたものはありません。C#例外は何ですか?
すなわち:
- UnauthorizedAccessException:I/O
- AccessViolationException:メモリーのもの
- SecurityAccessDeniedExceptionは:セキュリティ認証要求が失敗した場合にスローされるセキュリティ例外を表します。
など
私は、このために、例外の自分のタイプを作成する必要がありますか?メンバーシップユーザーがメソッド呼び出しのための十分な権限を持っていない場合、どのような例外を発生させるべきですか?