Routing works two ways - it will take in a request url and match the correct resource, or you can ask routing to generate you an URL based on the parameters you have.
RouteCollection.GetVirtualPath(
context,
new RouteValueDictionary(
{param1name, param1value},
{param2name, param2value}...
)
);
This will generate you a URL to the resource you'd like, based on your parameter values.
If you pass in "controller" = "whatever", "action" = "whatever", and "pagenumber" = currentpg, you should get the URL that you want, without having to manually parse the URLs. This is also more scalable should your routes change in the future.
Any extra parameters you pass into GetVirtualPath that are not consumed by the route matching will be appended as querystring parameters.
womp
2009-07-21 16:13:41