Ben Biddington

Whatever it is, it's not about "coding"

Posts Tagged ‘routes

Configuring routes in ASP.NET MVC

leave a comment »

Routes can be configured as follows:

routes.Add(
    new Route(
        "files/{id}",                        // URL pattern
        new RouteValueDictionary    // Defaults
        {
            { "controller"  , "file"},      // Default controller is file
            { "action"      , "index"},
            { "id"          , null}
        },
        new MvcRouteHandler()
    )
);

Which means an URL like:

/files/12345

returns the file with id equal to 12345.

Advertisements

Written by benbiddington

8 October, 2008 at 08:31

Posted in Uncategorized

Tagged with , ,