Improving urls in mvc2

Improving urls

Currently I have links in the form (displaying product information):


I want to clean this up into the form:


I think I need to do this with routes.MapRoute, something like so:

routes.MapRoute(null, "/Products/Page{page}", new {controller = "ProductController", action = "Index"});

This was put above the default route (so should override I am led to believe)

The product controller looks like this:

    // GET: /Products/
    public ActionResult Index([DefaultValue(1)] int page)
        var productsToShow = //omitted for simplicity

        var viewModel = new ProductIndexViewModel
                                ProductList = //omitted for simplicity,
                                PagingInfo = new PagingInfo
                                                     CurrentPage = page,
                                                     ItemsPerPage = PageSize,
                                                     TotalItems = productsToShow.Count()

        //Passed to view as ViewData.Model (or simply Model)
        return View(viewModel);

What am I doing wrong?


Change routes.MapRoute

routes.MapRoute(null, "Products/Page{page}", new {controller = "Products", action = "Index"});

Need Your Help

Python Fuse calling 'readlink' 6 times in a row

python linux fuse

I am implementing a filesystem using Python Fuse. A directory contains only symlinks and as such I return S_IFLNK | 0777 on the getattr method.

How to give single line border to gridview android

android gridview border cell

I have created gridview with customer adapter. To give each cell border, I have placed them in two layouts. The first layout has black bg and second layout has white bg and contents. and I have giv...