public void OnAuthorization(AuthorizationFilterContext context)
        {
            var customerID = CustomerSessionKey.GetCustomerID(context.HttpContext.Session);

            if (!customerID.HasValue)
            {
                context.Result = new RedirectToActionResult("Index", "Home", null);
            }
        }
コード例 #2
0
        public IActionResult Index()
        {
            int?customerIdNullable = CustomerSessionKey.GetCustomerID(HttpContext.Session);

            if (customerIdNullable == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            return(RedirectToAction("Index", "Customer"));
        }