How do I set Default Controller for my ASP.NET MVC 4 project without making it HomeController?
How should I setup a default Area when the application starts?
Defining a Default Controller To specify a default controller, open your application/config/routes. php file and set this variable: $route['default_controller'] = ' Blog '; Where Blog is the name of the controller class you want used.
By default, the Index() method is a default action method for any controller, as per configured default root, as shown below. routes. MapRoute( name: "Default", url: "{controller}/{action}/{id}/{name}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.
ActionResult is a return type of a controller method in ASP.NET MVC.
the best way is to change your route. The default route (defined in your App_Start) sets /Home/Index
routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters* new { controller = "Home", action = "Index", id = UrlParameter.Optional } );
as the default landing page. You can change that to be any route you wish.
routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters* new { controller = "Sales", action = "ProjectionReport", id = UrlParameter.Optional } );
Set below code in RouteConfig.cs in App_Start folder
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }); }
IF still not working then do below steps
Second Way : You simple follow below steps,
1) Right click on your Project
2) Select Properties
3) Select Web option and then Select Specific Page (Controller/View) and then set your login page
Here, Account is my controller and Login is my action method (saved in Account Controller)
Please take a look attached screenshot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With