Setting up a Controller and View


Creating an InSite Search controller

After building a query, the next step is to create a controller to add to your site. Download an example below. Most of the code parses user input and provides the view with the information it needs to render the results. Because the rendering of the results is not obfuscated, you can choose any method or library to help render the results. The example uses a Lucene.Net.Search.Highlight.Highlighter to help format the results.

Download an example controller.

Creating a view

The only thing left to do is create a view. Again, there is a certain amount of work that needs to be done in order to parse user input. The code sample included in this article is for a search results page. It also contains code to provide more-meaningful data to the client. For example, users could find out how many items of a certain category or type were returned in the search.

Download the example view.

After creating a view, place it in /Views/Search/Index.csthml.