0

I have created a new MVC project and whenever I start the project, "Index.cshtml" in Views is launched first. Where is this defined and how do i change it to some other page.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
Yagzii
  • 286
  • 3
  • 14

3 Answers3

2

Look for this setting, in global.asax.cs or in RouteConfig.cs under App_Start.

 routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

Change its default controller and action as per your requirement.

Sanjay Sahani
  • 565
  • 4
  • 14
0

In the App_Start folder open RouteConfig.cs. Change the defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } to whatever you like.

0

There is two way

  • change the default maproute

    routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "ABC", action = "XYZ", id = UrlParameter.Optional }
        );
    
  • change the action index -> view name

    return View("ViewName")
    
Amit
  • 15,217
  • 8
  • 46
  • 68