0

I have this route:

http://example.com/home/solucoes

But I Would to call like http://example.com/any-category/any-thing

My controlller is "Home" and action is "solucoes"

I try use it, but not work

  routes.MapRoute(
            name: "DefaultSolucoes",
            url: "{categoria}/{page}",
            defaults: new { 
                controller = "Home", 
                action = "solucoes", 
                categoria = UrlParameter.Optional,
                page = UrlParameter.Optional }
        );
3
  • How do you try to use it? Commented Jul 16, 2014 at 14:55
  • I want to use the same route/action, but with different urls for use in SEO Optimization. Commented Jul 16, 2014 at 15:00
  • is this the first route ? Commented Jul 16, 2014 at 15:03

1 Answer 1

2

Most likely you have that route below the default route. The problem there is that both of these routes are basically identical. So, when the default route catches, it simply looks for a controller named "any-category" and an action named "any-thing". Simply having different parameter names doesn't differentiate one route from another.

You can move your route above the default route, as routes are processed top down and the first match wins. However, you've then basically made this route the default route, as it will catch all your standard controller/action style URLs. You might consider adding a prefix to the route, for example:

url: "categoria/{categoria}/{page}",

So then your URLs would be in the form of /categoria/any-category/any-thing and you won't have any conflicts.

Sign up to request clarification or add additional context in comments.

1 Comment

Ahh nice! Thats work now Chris. I just put to above the default route and now work perfect! Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.