public ActionResult Create()
        {
            var userId    = Session["UserId"].ToString();
            var profileId = Session["ProfileId"].ToString();

            SqlHelper.DbContext();
            Users user = SqlHelper.GetUser(userId);

            HttpCookie cookie = FormsAuthentication.GetAuthCookie(user.UserName, true);
            var        ticket = FormsAuthentication.Decrypt(cookie.Value);

            FormsAuthenticationTicket authTicket = new
                                                   FormsAuthenticationTicket(1,                           //version
                                                                             ticket.Name,
                                                                             DateTime.Now,                //creation
                                                                             DateTime.Now.AddMinutes(60), //Expiration
                                                                             true, "");
            // Encrypt the ticket.
            string encTicket = FormsAuthentication.Encrypt(authTicket);

            // Create the cookie.
            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

            return(View(layoutViewModel.LayoutViewModelBuilder(profileId, userId)));
        }
예제 #2
0
        public ActionResult Index()
        {
            var    ctx      = System.Web.HttpContext.Current;
            string UserName = Session["UserName"].ToString();
            string logout   = (string)ctx.Session[UserName];

            if (logout == "logout")
            {
                return(View("~/Views/Account/Login.cshtml"));
            }
            LayoutViewModel layoutViewModel = new LayoutViewModel();

            ViewBag.Title = "Adultus";
            return(View(layoutViewModel.LayoutViewModelBuilder(Session["ProfileId"].ToString(), Session["UserId"].ToString())));
        }