I am having a bit of an issue with precendence. I've read through the documentation, but I have been unable to solve the problem.
I have the following site, "mysite.com". Within the site I have the route
[GET("{type}")]
That route lets me say "mysite.com/art", or "mysite.com/theatre".
My problem then, is that when I try to create a route for "mysite.com/venues", with the route
[GET("venues")]
It always tries to put "venues" as the parameter within the "Type" action.
I have tried adding
[GET("{type}"), ControllerPrecedence = -1]
... with no luck. I've also tried amending the RouteConfig with:
routes.MapRoute( name: "venues", url: "venues", defaults: new { controller = "Home", action = "Venues" } );
... also with no luck. Lastly, I tried:
routes.MapAttributeRoutes(config => { config.AddRoutesFromController(); config.AddRoutesFromController();
config.UseLowercaseRoutes = true; });
After splitting the actions out into a new controller, but again, nothing helped.
The only thing I can think to do is to change the route to be:
[GET("p/venues")]
... but that isn't the nicest of URLs.
Do you have any suggestions of what else I can try?
Thanks a load.
Andy
I figured out the problem. The route that I had mainly tested with took a parameter, but I'd missed making the parameter optional, so although it would have been hitting the route, because there was no parameter it went to the next in line.