I have the following route defined in global.asax
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Portal", action = "Index", id = UrlParameter.Optional }
);
I can't control whether users access the page with "/useraccount/edit/1" or "/useraccount/edit?id=1". When using the UrlHelper Action method to generate a url, the id value is not contained in RouteData if id is passed as a querystring parameter.
new UrlHelper(helper.ViewContext.RequestContext).Action(
action, helper.ViewContext.RouteData.Values)
I'm looking for a consistent way to access the id value, regardless of which url was used to access the page, or a way to customize the initialization of the RouteData object so that it checks the QueryString for missing route parameters and adds them if they are found.