Reputation: 2735
Rather than "/MyController/Index?teamId=3&type=4", MVC routing prefers :"/MyController/3/4". So what's the benefits of doing so? On the contrary, I am suffering many drawbacks of it. For example:
What's 3 and 4?
"Have you tested /MyController/3/4?""no, but I've tested /MyController/Index/3/4""..."
I have some js codes to make "current link" black text. For example, if a link on the page (usually a menu item) links to the page itself, the link will be changed to black text. But in this case, the link "/MyController/3/4" on page "/MyController/Index/3/4" cannot be processed properly.
So why should we use MVC routing like that? And how should I overcome the 3rd problem listed above? That's why I'm here :)
Thanks for any hint.
Upvotes: 0
Views: 364
Reputation: 2982
You would be much better off with routing using actual string names instead of IDs where you can get away with it... such as /Teams/TeamNameOrAbbreviation/TeamType
Different links pointing to the same pages stems from the defaults set in the routeconfig. If you do not want this to happen, you can change how you are handling your defaults.
You can process the links properly if you use MVC's built in methods to do so. You can resolve URLs using helpers such as @Url.Action() for comparison and usage in js code since it always generates the same one every time.
Upvotes: 1
Reputation: 7525
It's not MVC Routing where you got confused. What you need to understand is SEO friendly urls. These url("MyController/3/4") helps search engines to easily find the pages.
Have a look at these links. You'll have a better reason.
Upvotes: 0