Taking Search Input and Returning Result(s)

This book store really needs a search function. One notable difference is whether to return a single value, e.g. one person matching a phone number, or multiple values, e.g. a list of books.

A little modification to the Home Controller and the Index View will get us an input field and an output field for displaying results. For now, this will involve a full postback, reloading the page. In the single result example, it will send the user to the detail page for that item. In the list example, it will refresh the index page with the result. In case there are no results, I’ll provide some feedback that nothing was found.




Resulting redirect to /Authors/Details/1

Redirect to Details





Users should be alerted in the event nothing is found, i.e. when results.Count == 0.

No Unicorns