示例#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));
        }
        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" }));
                }
            }
        }