public IActionResult Index(LoginModel model)
        {
            //  HttpContext.Session;
            UserBl ubl = new UserBl();

            if (ubl.GetAUser(model.userName, model.password) != null)
            {
                // HttpContext.Session["un"] = new DistributedSessionStore();
                HttpContext.Session.SetString("username", model.userName);
                HttpContext.Session.SetString("password", model.password);
                // HttpContext.Items["username"]= model.password;
                // HttpContext.Session.SetString("un", model.userName);
                Console.WriteLine(HttpContext.Session.GetString("un"));
                ViewData["wrong"] = "";
                ViewData["Acc"]   = model.userName;
                return(View("About"));
            }
            ViewData["wrong"] = "Invalid pasword or account!\nRe-enter password.";
            return(View());
        }
        public IActionResult Index()
        {
            ViewData["wrong"] = "";
            UserBl ubl = new UserBl();

            // byte[] us;
            // byte[] pw;
            // ISession s = DefaultHttpContext.
            // try
            // {
            //     // ViewBag.name = ;
            // }
            // catch (System.Exception)
            // {

            //     throw;
            // }
            Console.WriteLine(HttpContext.Session.GetString("username") + "===================");

            if (HttpContext.Session.GetString("username") != null)
            {
                // string user = us.ToString();
                // string pass = pw.ToString();
                if (ubl.GetAUser(HttpContext.Session.GetString("username").ToString(), HttpContext.Session.GetString("password").ToString()) != null)
                {
                    // HttpContext.Session["un"] = new DistributedSessionStore();
                    // HttpContext.Session.SetString("username", model.userName);
                    // HttpContext.Session.SetString("password", model.password);
                    ViewData["wrong"] = "";
                    ViewData["Acc"]   = HttpContext.Session.GetString("username").ToString();
                    return(View("About"));
                }
            }
            var model = new LoginModel();

            return(View());
        }
Exemple #3
0
        public void Test1()
        {
            UserBl ubl = new UserBl();

            Assert.NotNull(ubl.GetAUser("account1", "password1"));
        }