asp.net mvc 5 - Remove controller 'Home' from URL in MVC 5 -


i need remove controller 'home' url of project, looks this: example.com/home/contact , want this: example.com/contact (also other sections services, our-team, gallery, etc.)

i tried remove '{controller}' appears before '{action}/{id}' in routeconfig.cs code, this:

namespace myproject { public class routeconfig {     public static void registerroutes(routecollection routes)     {         routes.ignoreroute("{resource}.axd/{*pathinfo}");          routes.maproute(             "default",             "{action}/{id}",             new { controller = "home", action = "index", id = urlparameter.optional }         );     }     } } 

and controller 'home' disappears url, following links login , manage not work:

@html.actionlink("login here", "login", "account") @html.actionlink("manage website", "index", "manage") 

how make links work without displaying controller 'home' in url?

you'll need add following routeconfig.cs

    routes.maproute(         name: "contact",         url: "contact",         defaults: new { controller = "home", action = "contact" }     ); 

make sure "default" route mapping last one.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -