Question

I've this set up as routevalue:

routes.MapRoute(
    name: "Overview",
    url: "Overview/{controller}/{action}/{id}",
    defaults: new { module = "Overview", controller = "Core", action = "List", id = UrlParameter.Optional },
    namespaces: new[] { "myproject.Controllers.Overview" }
);

routes.MapRoute(
    name: "Store",
    url: "Store/{controller}/{action}/{id}",
    defaults: new { module = "Store", controller = "Core", action = "List", id = UrlParameter.Optional },
    namespaces: new[] { "myproject.Controllers.Store" }
);

You can see that both my controller have same method and I distinguishes them by specifying namespace. This is done to create modules among the controllers.

But now when I am designing the layout class, I can't use Actionlink as in Actionlink I don't know how to specify namespace... any idea?

Was it helpful?

Solution

You can't specify a namespace, it's inferred from the namespace of the current controller. Whichever controller's action is called, that will be the namespace MVC will interpret the route with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top