Getting routing parameters

Topics: Writing modules
May 17, 2012 at 1:04 PM


I have a route setup in my module in the Routes.cs file.

It is routing fine, but I want to get the parameters out of the route.

Here is the route:

return new[] {
                new RouteDescriptor {
                    Priority = 5,
                    Route = new Route(
                        new RouteValueDictionary {
                            {"area", "DealInformation"},
                            {"controller", "Home"},
                            {"action", "Index"},
                            {"PackageID", "PackageID"},
                            {"SupplierID", "SupplierID"}
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "DealInformation"}
                        new MvcRouteHandler())

When in my controller I want to be able to get the value of "PackageID" and "SupplierID".

How can I do this?

Thanks :)

May 17, 2012 at 2:29 PM

I solved it.

For anybody else who needs to know:


May 17, 2012 at 5:14 PM
Edited May 17, 2012 at 5:15 PM

if I understand correctly a much more straightforward solution would be to just add the arguments packageId and supplierId to your action's signature. The model binder will fill them with the appropriate data.