Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
All-Star
134832 Points
21599 Posts
Moderator
MVP
Apr 15, 2010 03:59 PM|LINK
Qty I have read that article before, but please note, I have both id and slug at the url.
Yes, that what he have too
Note that
1. The url has a slug and a ID
2. The action method has the parameter just id
3. The action filter has a method that adds the id from the slug ( Slugs.TryGetValue(slug, out id); )
public override void OnActionExecuting(ActionExecutingContext filterContext) { var slug = filterContext.RouteData.Values["slug"] as string; if(slug != null) { int id; Slugs.TryGetValue(slug, out id); filterContext.ActionParameters["id"] = id; } base.OnActionExecuting(filterContext); }
ignatandrei
All-Star
134832 Points
21599 Posts
Moderator
MVP
Re: MapRoute does not match other '-'s when '-' is used as a 'path separator'
Apr 15, 2010 03:59 PM|LINK
Yes, that what he have too
Note that
1. The url has a slug and a ID
2. The action method has the parameter just id
3. The action filter has a method that adds the id from the slug ( Slugs.TryGetValue(slug, out id); )