0
I am fixing some URL’s of my site and need to create several different routes for each page, for example:
routes.MapRoute(
name: "ComoVenderMinhasImagens",
url: "como-vender-minhas-imagens",
defaults: new { controller = "Home", action = "ComoVenderMinhasImagens", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "PerguntasFrequentes",
url: "perguntas-frequentes",
defaults: new { controller = "Home", action = "PerguntasFrequentes", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "FormasdePagamento",
url: "formas-de-pagamento",
defaults: new { controller = "Home", action = "FormasdePagamento", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "BancoDeImagens",
url: "banco-de-imagens",
defaults: new { controller = "Home", action = "BancoDeImagens", id = UrlParameter.Optional }
);
As in the example, I need to create URL’s in which words are separated by -
in some cases, there is some framework tool that allows me to create a generic route that works for any type of Action whatever the number of words?
(Stock-of-images && how-to-sell-my-images && Frequently Asked Questions && Questions)
You wanted a route that received in the url any set of words separated by - and forwarded to action that in the name does not contain the - ?
– Alisson Marqui
That, or the other way around, he was named after Action
FormasDePagamento
and automatically separate maybe through the upper case and put the-
– Leonardo Bonetti
Because I can’t put public Actionresult forms-of-payment then I would need to put Formasdepaming and route automatically separate
– Leonardo Bonetti
An option would be to annotate actions with the attribute [Route("name-of-your-route")], this suits you ?
– Alisson Marqui