Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- asp.net mvc keep object alive, information
- [HttpPost]
- public ActionResult Index(LoginModel loginModel)
- {
- if (ModelState.IsValid)
- {
- // some lines of code . bla bla bla
- TempData["loginModel"] = loginModel;
- return RedirectToAction("index", "premium");
- }
- ...
- }
- public ActionResult Index()
- {
- var loginModel = TempData["loginModel"] as LoginModel;
- ...
- }
- Object reference not set to an instance of an object.
- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
- Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
- Source Error:
- Line 22:
- Line 23: var loginModel = TempData["loginModel"] as LoginModel;
- Line 24: string username = loginModel.username;
- Line 25: string password = loginModel.password;
- Line 26: premiumModel.username = username;
Add Comment
Please, Sign In to add comment