سؤال

I have a portable area in a separate assembly and want its View to populate via a call to RenderBody() in the shared _Layout.cshtml found in the main assembly. But the result I get is the contents of the View alone, as if _Layout.cshtml isn't even rendered. Further, none of the regions defined in the View (in the portable area) are rendered either - which is actually sort of expected since _Layout.cshtml seems to be ignored altogether.

So am I doing something wrong or am I misunderstanding how portable areas are designed to work? I was really hoping to use this functionality to move Views and regions to portable areas while maintaining the "master page" functionality in the main web application.

هل كانت مفيدة؟

المحلول

Apparently, portable areas must define the Layout they wish to be wrapped by. This fixed the issue, added to the View in the portable area:

@{ Layout = "~/Views/Shared/_Layout.cshtml"; }

I stumbled onto this which helped me, albeit indirectly:

http://mvccontrib.codeplex.com/workitem/7126

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top