I would probably have a search action that displays a result with search results if there are multiple results. It could reuse the list view if necessary, but it would be easier to just display them, rather than trying to redirect to another action with multiple identifiers. In the case of a single result, redirection to the action of information for this element may be required. This would mean that I would need to get enough data during the search to populate the model for the list. If you are redirected to an action with details, you simply redirect by id and allow the action of the part to receive any information necessary to display it.
public ViewResult Search( string query ) { ... get results .. if (results.Count() == 1) { return RedirectToAction( "details", new { id = results.First().ID } ); } return View( "list", this.CreateListViewModel( results ) ); }
where CreateListViewModel takes a set of search results and creates a view model object to represent the list.
source share