How do you keep the value of global variables between different Action Methods calls in MVC3?

后端 未结 5 1574
迷失自我
迷失自我 2021-01-04 01:48

I am developing an ASP.NET MVC 3 web application using Razor and C#.

I just discovered that I have some problems with global variables, probably because I am relati

5条回答
  •  隐瞒了意图╮
    2021-01-04 02:20

    You should probably use ViewData for this OR use the HttpContext. ViewData will only be valid for your current request so is generally a better alternative than directly using the session object since your data is removed and not available on the next request. Using the session object can suffer from multi request overlap issues.

提交回复
热议问题