Arun Kumar
Arun Kumar

Reputation: 59

How to set default url or startup page in asp.net core 2.2

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

Answers (1)

Ryan
Ryan

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

Related Questions