I have two controller based on user type in my ASP.NET Core project. One is AdminController
for admin and one is UserController
for users. And there is also HomeController
for signin and contact page. I am using following map route configuration for both admin and user controllers.
config.MapRoute(
name: "UserRoute",
template: "{controller}/{username}/{action}",
defaults: new { controller = "User|Admin", action = "Dashboard" }
);
By using above route config I am getting following types of Urls
/User/user1
/Admin/user2
I don't want the Admin
and User
part in URL instead I want
/user1
/user2
How to remove User
and Admin
part from the URL? If I remove controller from {controller}/{username}/{action}
and specify only controller in defaults then it only works for one controller.