asp.net mvc keep object alive, information

前端 未结 4 366
梦如初夏
梦如初夏 2020-11-30 13:17

i have this code

[HttpPost]
public ActionResult Index(LoginModel loginModel)
{
    if (ModelState.IsValid)
    { 
       // some lines of code . bla bla bla
         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 13:45

    TempData does only live for one request. Therefore it's empty when you make the second request. If you'd want to do it like this you should use Session instead or you can have a look at forms authentication.

    You should also consider VinayC advice and not store any password information in any state, especially not in clear text format.

提交回复
热议问题