Remove controller name from mvc url

I want to do something similar to this post:

How to hide controller name in url?

only without any identifiers.

The server starts IIS 6 and the pages are already displayed without extensions, so this is not a problem with the templates.

I want to click http://website.com/action-name

I have http://website.com/controller/action-name working

I guess this is just a simple route change that I am sorting through somehow. My current routing rule is:

routes.MapRoute(
    "RouteName",
"{action}",
new { controller = "Home", action = "Index" }
);
+5
source share
2 answers

{controller, action, id}, ?

+7

, , , , , . , controller/action, , . RegisterRoutes?

, , , .

EDIT: , RegisterRoutes:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    // This will match anything so if you have something very specific with hard coded
    // values or more items that will need to be match add them here above but do not
    // add defaulted values so it can still fall through to this.
    routes.MapRoute( 
        "RouteName", 
        "{action}", 
        new { controller = "Home", action = "Index" });
}
+2

All Articles