I created an empty MVC4 Application, all things are working fine, after that I add an Area to my Project Named \"Moderator\". My area routing code is like this:
Just add the "namespace:" named parameter in RegisterRoutes()
method of RouteConfig.cs
in App_Start
folder. And specify the value of "namespace" to the namespace of your controller, within which you want to call action method.
In following example i want to call Index()
method in Village Controller from root of project.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Village", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "MvcApplication1.Controllers" }
);
}