O'Reilly logo

ASP.NET MVC 2 Cookbook by Richard Kimber, Andrew Siemer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Supporting pagination in your URLs

This recipe is sort of a mix of routing and tomfoolery. While the routing aspect of this is pretty simple, the underlying bits that populate the URL can be a bit more complex. For that reason, we will cover both the routing aspect and a reusable control for managing pagination in any data set.

How to do it...

  1. Create a new MVC application.
  2. Add a reference to NBuilder (in the dependencies folder), so that we can create some data to play with.
  3. Then open up your Global.asax, so that we can add a new route to handle paging. We will create a route that will allow us to use our HomeController without the customer knowing it, and that will expose a page variable instead of the id variable. Also, instead of making the page ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required