0

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?

Hossain Muctadir
  • 3,546
  • 1
  • 19
  • 33

1 Answers1

1

I think this will work:

Html.RenderAction("action", "controller", new { area = "" })
jorgehmv
  • 3,633
  • 3
  • 25
  • 39
  • the third parameter receives additional route information so sending it a parameter called area with an empty string will tell MVC that it should route the request to the default area. I know an overload would be much better, maybe MVC4 will include it. – jorgehmv Apr 09 '12 at 19:56