Update - this question was originally not about session states.
I am trying to change a variable in the user state in MVC 5
// POST: /Account/Registered [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Registered(loggedinViewModel model, ApplicationUser user, string selcteditem) { if (ModelState.IsValid) { var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new UserDb())); var store = new UserStore<ApplicationUser>(new UserDb()); var currentUser = manager.FindById(User.Identity.GetUserId()); var newCID = clubIDMethod(); var ctx = store.Context as UserDb; ctx.Users.Attach(user); SelectedNewCID(model, newCID); ViewBag.newCID = (model.SelectedGodCID); user.CID = ViewBag.newCID; currentUser.CID = user.CID; } return View(model); } I am really unsure what the state is not being saved, the currentUser.CID is being updated but then when I go else where it's still set to the original value
Please Help Thanks
currentUserdeclared? Do you understand a new controller is instantiated for each request? Have you heard of session?