I need some help on this problem. It is about ASP.NET MVC3. I have a page with at the top some search criteria and at the bottom the resulting data. The user can type some criteria and use a submit button to retieve data. In my controller, I have an ActionResult function for managing these criteria and return to the same page with a ViewModel class filled.
The problem: the user can click on a line in the resulting table for viewing a detail page. On the detail page, he can navigate to an edit page for editing data. On this page (edit data) I would like to able the user to go back to the search result page (in fact: navigate back two times). What is the best way to proceed? If I “simply” use an ActionLink (without posting data) to my search result page, it will simply display an empty result page with empty search criteria. Maybe I need to keep my search criteria in a session variable? I don’t like this kind of thing…
Any help will be highly appreciated.
Why not place the data in the
Session, as you say?This way you have the search criteria available no matter how many “back clicks” the user does.
You could make it much more complicated but I do not think it is necessary in this case. If you want to pass it as route data in an action link you’ll have to defensively add a
searchCriteriaparameter to every ActionLink of the pages the user might navigate to from the Search page. That makes it a lot more cumbersome in my opinion.Good enough is sometimes good enough. Refactor later as needed. 🙂