views:

16

answers:

1

I need to create a custom route to list all the rooms in a given building. So, I want the url to look something like this:

/Building/1000/Room

Which would list all the rooms in Building 1000.

Is this the correct mapping for the route (to call the IndexByBuilding method in RoomController)?

        routes.MapRoute(
            "RoomsByBuilding",
            "Building/{id}/Room",
            new { controller = "Room", action = "IndexByBuilding", id = "" }
            );
A: 

Your route looks good to me. Make sure you move it up to the top of your route table to avoid conflicts.

Bradley Mountford