0

I want to Render Index() action off my Area (named Menu) in Layout Page of my main MVC project by this code

and got Error on this line of layout

@{Html.RenderAction("Index", "Menu", new { area = "" }); }

Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.

and this is my AreaRegistration Code just for inform:

        public override string AreaName
    {
        get
        {
            return "Menu";
        }
    }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Menu_default",
            "Menu/{controller}/{action}/{id}",
            new { controller = "Menu", action = "Index", id = UrlParameter.Optional },
            new string[] { "Menu.Controllers" }
        );

    }

as you see my controller name is Menu

Edited: the main reason of my problem is this ...Index action off my area cant return his view ...i was set one break point in Index action, and one break point inside of Index view ... and the program is reaching and stop on first one,but never stops in second one!! ... So the main problem is this ...Index action of my area doesn't return Index view..

Iman Salehi
  • 908
  • 2
  • 14
  • 34
  • 1
    Possible duplicate of [Error executing child request for handler in view](http://stackoverflow.com/questions/19272720/error-executing-child-request-for-handler-in-view) – caesay Jan 23 '17 at 15:41
  • Your are in the Menu area, and you do not speficy any area in Html.RenderAction : new { area = "Menu" }); – Laurent Lequenne Jan 23 '17 at 15:42
  • @LaurentLequenne i want to render action inside my main projects Layout page ...if i specify Area name. it brings another logical error ...because rendered actions (which are inside layout) shouldn't have parent page ... – Iman Salehi Jan 24 '17 at 07:30

2 Answers2

0

Try this One

  @Html.Action("Index", "Menu")
ADNAN ZAMAN
  • 68
  • 1
  • 10
-1

i solve it. actually, only solution to do this thing was using RenderPartial with direct path:

 @{ Html.RenderPartial("~/Areas/Menu/Views/Menu/Index.cshtml");}
Iman Salehi
  • 908
  • 2
  • 14
  • 34