In my last blog post I walked through a simple example of how to
implement a /Products URL that renders a list of product categories:
Below is a simple ProductsController implementation that
implements the /Products URL above. It retrieves a list of product
categories from a database, and then passes them off to a view file to render
an appropriate HTML response back to the browser:
Here is what the Index.cshtml view file (implemented using
Razor) looks like:
The above view file does not yet use a layout page – which
means that as we add additional URLs and pages to the site we’ll end up
duplicating our core site layout in multiple places. Using a layout will
allow us to avoid this duplication and make it much easier to manage our site
design going forward. Let’s update our sample to use one now.