How to pass values from One controller to another Controller in ASP.Net MVC3

后端 未结 4 720
青春惊慌失措
青春惊慌失措 2021-01-14 08:19

Hello In my project I have to pass a welcome message with username to the Index Page Its a MVC3 ASP.Net Razor project

There are two controllers are there; O

4条回答
  •  自闭症患者
    2021-01-14 08:58

    Use TempData. Its data is available in the next request also.

    // after login
    TempData["message"] = "whatever";
    
    // home/index
    var message = TempData["message"] as string;
    

提交回复
热议问题