Мне нужно сделать другой маршрут между dev env и prod env ..
для dev, я ожидаю использовать http://localhost:5000
но для прод я ожидаю использовать http://example.com/mdc
Я попробовал ниже при запуске
app.UseMvc(routes =>
{
if (env.IsDevelopment())
{
routes.MapRoute(
name: "login_dev",
template: "{controller=Account}/{action=Login}/{id?}",
defaults: new { controller = "Account", action = "Login" });
}
else
{
routes.MapRoute(
name: "login_prod",
template: "mdc/{controller=Account}/{action=Login}/{id?}",
defaults: new { controller = "Account", action = "Login" });
}
routes.MapRoute(
name: "default",
template: "{api}/{controller}/{action}");
});
Я получил:
Application startup exception
Microsoft.AspNetCore.Routing.RouteCreationException: An error occurred while creating the route with name 'login_prod' and template 'mdc/{controller=Account}/{action=Login}/{id?}'. ---> System.InvalidOperationException: The route parameter 'controller' has both an inline default value and an explicit default value specified. A route parameter cannot contain an inline default value when a default value is specified explicitly