Hoje esbarrei com um problema com rotas no meu adorado MVC.
Se você colocar isso:
context.MapRoute(
"Facebook",
"Facebook/{controller}/{action}/{id}",
new { controller = "Usuario", action = "Inicio", id = UrlParameter.Optional },
new[] { typeof(UsuarioController).Namespace }
);
context.MapRoute(
"Corretores",
"Corretores/{controller}/{action}/{id}",
new { controller = "Usuario", action = "Inicio", id = UrlParameter.Optional },
new[] { typeof(UsuarioController).Namespace }
);
context.MapRoute(
"Facebook",
"Facebook/{controller}/{action}/{id}",
new { controller = "Usuario", action = "Inicio", id = UrlParameter.Optional },
new[] { typeof(UsuarioController).Namespace }
);
context.MapRoute(
"Corretores",
"Corretores/{controller}/{action}/{id}",
new { controller = "Usuario", action = "Inicio", id = UrlParameter.Optional },
new[] { typeof(UsuarioController).Namespace }
);
Quando
você estiver em uma página com a url /Corretores, os links apontarão
para /Facebook. Não só isso, se houver redirecionamento (ex: RedirectToAction, no controller), também irá para /Facebook. Para consertar isso, você pode fazer a coisa horrorosa
abaixo e tudo ficará bem (menos a sua consciência).
context.MapRoute(
"Facebook",
"Face{book}/{controller}/{action}/{id}",
new { controller = "Usuario", action = "Inicio", id = UrlParameter.Optional },
new[] { typeof(UsuarioController).Namespace }
);
context.MapRoute(
"Corretores",
"Corretores/{controller}/{action}/{id}",
new { controller = "Usuario", action = "Inicio", id = UrlParameter.Optional },
new[] { typeof(UsuarioController).Namespace }
);
Nenhum comentário:
Postar um comentário