RedirectToAction usage in asp.net mvc

后端 未结 4 441
甜味超标
甜味超标 2020-12-28 13:34

I want to post some questions about ASP.Net MVC. I am not familiar with web developing, But I was assigned to the web part of a project. We are doing the follow

4条回答
  •  渐次进展
    2020-12-28 13:57

    Temp data is capable of handling single subsequent request. Hence, value gone after refresh the page. To mitigate this issue, we can use Session variable also in this case. Try below:

    public ActionResult Index(Person _person)
    {
        Session["personNickName"] = _person.nickName;
        return RedirectToAction("profile", "person");
    }
    

    And in "profile" actionmethod:

    public ActionResult profile()
    {
        Person nickName=(Person)Session["personNickName"];
        if(nickName !=null)
        {
        //Do the logic with the nickName
        }
    }
    

提交回复
热议问题