In asp.net MVC the "homepage" (ie the route that displays when hitting www.foo.com) is set to Home/Index .
I tried grepping for Home/Index in my project and couldn't find a reference, nor could I see anything in IIS (6). I looked at the default.aspx page in the root, but that didn't seem to do anything relevent.
Thanks
Select Admin Tools --> IIS Manager --> Select your website from the list. Click on Default Document on the right hand side and Click Add . Move the entry to the top of the list using the arrows. You are done.
Select the Web tab on the left-hand side. Under the Start Action section, define the Specific Page you would like to default to when the application is launched.
Look at the Default.aspx/Default.aspx.cs
and the Global.asax.cs
You can set up a default route:
routes.MapRoute( "Default", // Route name "", // URL with parameters new { controller = "Home", action = "Index"} // Parameter defaults );
Just change the Controller/Action names to your desired default. That should be the last route in the Routing Table.
Routing is configured in the Configure
method of the Startup
class. To set the "homepage" simply add the following. This will cause users to be routed to the controller and action defined in the MapRoute method when/if they navigate to your site’s base URL, i.e., yoursite.com will route users to yoursite.com/foo/index:
app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=FooController}/{action=Index}/{id?}"); });
Use the RegisterRoutes method located in either App_Start/RouteConfig.cs (MVC 3 and 4) or Global.asax.cs (MVC 1 and 2) as shown below. This will cause users to be routed to the controller and action defined in the MapRoute method if they navigate to your site’s base URL, i.e., yoursite.com will route the user to yoursite.com/foo/index:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // Here I have created a custom "Default" route that will route users to the "YourAction" method within the "FooController" controller. routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "FooController", action = "Index", id = UrlParameter.Optional } ); }
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