Reputation: 691
I want to create some SEO friendly URL.
Following is my Global.ascx entry:
routes.MapRoute( "Product", "{action}/{param1}/{id}", new { controller = "Home", action = "Index" }); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
First Mapping is because i don't want to display my controller name in url. Next Mapping is for rest of the URL.
Problem is there are some URL which gives me an error like:
http://localhost:1234/index/my-product-information/12 : PASS http://localhost:1234/contentcontrol/index : PASS http://localhost:1234/contentcontrol/index/12 : FAIL
here, index : ACTION NAME contentcontrol : Controller Name
How should i resolve this.
Thanks in advance.
Upvotes: 0
Views: 242
Reputation: 7135
The problem you've got is that there's nothing to differentiate your first route from your second when it comes to requests to URLs with 3 segments, so the first route catches all those requests and 'hides' the second one. To get around it you'll have to differentiate the two routes, for example by making the first route pattern:
"/Go/{action}/{param1}/{id}"
Upvotes: 0