locked
How can I make this route works?? RRS feed

  • Question

  • User-1526811397 posted
    Hi everyone!! My HomeController is controlling some pages like 'Index' and some others like 'Contact', 'About Us'. But, if I type: www.blabla.com/ the 'Index' will be called and it works. But, if I type: www.blabla.com/AboutUs it doesn't work at all! It just works if I type: www.blabla.com/Home/AboutUs How can I make all the actions in HomeController work without typing "Home" before them? thanks!!!
    Saturday, February 28, 2009 1:37 PM

Answers

  • User-1384221439 posted

    If you are using default routing then www.blabla.com is the same as www.blabla.com/Home/Index. If you want to ommit Home from your URLs then you should change code in global.asax.cs in this way:

    routes.MapRoute(
        "Default",                                              // Route name
        "{action}/{id}",                           // URL with parameters
        new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
    );
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 28, 2009 4:37 PM