0

On my project I have only one controller so I want to do this:

http://www.example.com/{action}/{optional id}

All actions will be of a defined controller.

1 Answer 1

1

Change the path templates in the Global.asax

there will be something like

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // route
new { controller = "Home", action = "Index", id = UrlParameter.Optional }); // defaults
}

to change to something like

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                "Default", // Route name
                "{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.