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.
Asked
Active
Viewed 83 times
0
-
check this link http://stackoverflow.com/questions/8470416/how-to-set-a-default-page-on-an-mvc-app – Jaimin Soni Aug 28 '14 at 09:10
-
Check this link http://stackoverflow.com/questions/8470416/how-to-set-a-default-page-on-an-mvc-app – Jaimin Soni Aug 28 '14 at 09:11
3 Answers
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.

joumasehare
- 36
- 2
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