Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can do it a couple of ways, one way would be to have a controller for each area and each controller to have one Index action. This would create Urls as required with limited configuration of routing.</p> <p>The other method would be to have one controller and multiple actions (one for each Home , AboutUs, Products) and set the route to be something like this (untested) ...</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "/{action}/{id}", // URL with parameters new { controller = "Home", action = "Home", id = UrlParameter.Optional } // Parameter defaults ); } </code></pre> <p>Hope this helps.</p> <p><strong>Edit</strong></p> <p>Just checked the following code with the following assumptions -</p> <p>1 Controller (HomeController)</p> <p>In Global.ascx</p> <pre><code> public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); } </code></pre> <p>In HomeController</p> <pre><code>public class HomeController : Controller { public ActionResult Index() { ViewData["Message"] = "Welcome to ASP.NET MVC!"; return View(); } public ActionResult AboutUs() { return View(); } } </code></pre> <p>This will allow for:</p> <blockquote> <p><a href="http://localhost:port/" rel="nofollow">http://localhost:port/</a></p> <p><a href="http://localhost:port/index" rel="nofollow">http://localhost:port/index</a></p> <p><a href="http://localhost:port/aboutus" rel="nofollow">http://localhost:port/aboutus</a></p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload