ASP.NET MVC2 CategoryTree Routing
I have in SQL DB table:
Categories:
int CategoryID开发者_运维问答 int ParentID string Name
I want make link somelike this : localhost://(Name)/(Name)/(Name) and the last (Name) is selected category.
Real example: localhost://Sports/Vodni-Polo/Balls
Problem: in DB is name of category Vodni-Polo is Vodní pólo. On link creating i translate name to SEO link shape (Vodni-Polo).
How i can get category id wihout sending extra get parametr (Sports/Vodni-Polo/Balls/?categoryId).
I get Full tree of category from DB all time, but i must know witch items i can display it.
What i want: If i click at category, send GET req.(localhost://Sports/Vodni-Polo/Balls) a from this i want know whot id have (Balls)
You can make the Name a Unique key so you can query by it and guarantee uniqueness. Alternatively a common solution is to do something like {controller}/{action}/{Name}-{Id}
精彩评论