Recently I have switched from JSF to ASP.NET and I'm missing an important function: The ViewScope. I want to reproduce the behaviour of a ViewScoped controller.
example: I have a list of names and a page that shows an input field for every name in that list that lets you edit them. At the bottom is a button that adds a new empty item to the list.
In JSF this would be pretty easy. Set the controller to @ViewScoped and link the button to a method that adds a new empty item to the list and then rebuild the view. The new item would then be there in the form of an empty input field.
As far as I know, ASP.NET only lets you save data in the session storage. I would prefer not to use that because I want the empty object to vanish in case the user changes the page without hitting the save button.
I could add the input field via JavaScript but then I don't know how to retrieve the data in the controller. In my actual application there are a lot of input fields that need to be added, so working with JavaScript would be difficult. Additionaly I would have to update the page as well as the Javascript in case someting changes.
I would really prefer to do this on the server side.
How could I approach this problem?