コード例 #1
0
        public ActionResult Logout()
        {
            BlogAuthentication aut = new BlogAuthentication();

            aut.LogOut();

            List <Article> aList = GetData();

            ViewData["Category"] = GetCategory();
            return(View("Index", aList));
        }
コード例 #2
0
        public ActionResult Login(string userName, string password)
        {
            BlogAuthentication aut = new BlogAuthentication();

            aut.Login(userName, password);

            List <Article> aList = GetData();

            ViewData["Category"] = GetCategory();

            return(View("Index", aList));
        }
コード例 #3
0
        public void OnAuthentication(AuthenticationContext filterContext)
        {
            BlogAuthentication aut = new BlogAuthentication();

            if (filterContext.ActionDescriptor.ControllerDescriptor.ControllerName == "Comment" ||
                filterContext.ActionDescriptor.ControllerDescriptor.ControllerName == "Article" ||
                filterContext.ActionDescriptor.ControllerDescriptor.ControllerName == "Category")
            {
                if (!aut.IsAuthenticated())
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index" }));
                }
            }
        }