Search code examples
asp.net-mvc-3-areas

MVC3 Routing From an area to default


Working on an MVC3 project. I have an area named "Area" with an areaRegistration like this,

        context.MapRoute(
            "Area_Details",
            "Area/{controller}/{AreaId}/{AreaName}/{id}/{action}",
            new { controller = "Area", action = "Index" }
        );

        context.MapRoute(
            "Area_default",
            "Area/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional }
        );

I have another controller in /Controller "Home" with action "Details" which returns a PartialView.

From a view in the "Area" area I am trying to

@Html.RenderAction("Details","Home", new{ myId = 1})

which should access /home/details?myId=1 but it is trying to access /area/home/details?myId=1

how can I solve this problem?


Solution

  • I think this will work:

    Html.RenderAction("action", "controller", new { area = "" })