Reputation: 59
When i'm creating routing in asp.net core 2.2 with companyname and controller. My application shows 404 error for the following code when I hit F5.
app.UseMvc(route =>
{
route.MapRoute("Default", "MyCompany/{controller=Home}/{action=Index}/{id?}");
});
If I enter the full path it is working.
If I remove MyCompany before the controller, It works fine.
Please help me to fix this issue.
Upvotes: 0
Views: 1193
Reputation: 20139
Try to configure your routing to:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "startupRoute",
template: "/",
defaults: new { controller = "Home", action = "Index" }) ;
routes.MapRoute(
name: "default",
template: "MyCompany/{controller=Home}/{action=Index}/{id?}");
});
Upvotes: 1