You need to handle the two separate scenarios separately.
#1 While handling a single web request, your controller will run, and then your selected view will run. Data can go from controller to view in ViewData and in TempData, or any of the mechanisms in #2 (but this would be odd).
#2 Data that needs to cross from one response to the next request. Here you can use the client (hidden form fields (look how ViewData is sent to the client in a web forms app), form fields, cookies), or held on the server: session, application or some persistent
store.
Each option has different trade offs, and many many pages have been written about them. E.g. by default a session will not survive a server restart (including process cycling) or use of a server farm, but can be configured (at some incremental performance
overhead) to handle these cases.
The simplest, until you understand requirements in detail would be either hidden form fields (with some integrity verification) or use the web app's session (I would likely go for the latter as the easiest).
rjcox
Contributor
7064 Points
1444 Posts
Re: how handle internal controller state between steps
Jan 15, 2008 09:00 AM|LINK
You need to handle the two separate scenarios separately.
#1 While handling a single web request, your controller will run, and then your selected view will run. Data can go from controller to view in ViewData and in TempData, or any of the mechanisms in #2 (but this would be odd).
#2 Data that needs to cross from one response to the next request. Here you can use the client (hidden form fields (look how ViewData is sent to the client in a web forms app), form fields, cookies), or held on the server: session, application or some persistent store.
Each option has different trade offs, and many many pages have been written about them. E.g. by default a session will not survive a server restart (including process cycling) or use of a server farm, but can be configured (at some incremental performance overhead) to handle these cases.
The simplest, until you understand requirements in detail would be either hidden form fields (with some integrity verification) or use the web app's session (I would likely go for the latter as the easiest).