通常の認証
- // コントローラクラスで認証設定
- [Authorize]
- public ActionResult Index()
- {
- return View();
- }
カスタム認証
- // カスタムクラスの作成
- public class CustomAuthorizeAttribute : AuthorizeAttribute
- {
- protected override bool AuthorizeCore(HttpContextBase httpContext)
- {
- // ・・・認証処理を記述する・・・
- return true;
- }
- }
- // コントローラクラスで認証設定
- [CustomAuthorize]
- public ActionResult Index()
- {
- return View();
- }
という感じで、AuthorizeAttributeクラスを継承してやるとできる。
参考
SCHOTIME.NET
David Hayden
0 件のコメント:
コメントを投稿