JinDave
JinDave

Reputation: 21

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)

Upvotes: 2

Views: 83

Answers (1)

Vadim
Vadim

Reputation: 17957

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}

Upvotes: 1

Related Questions