Go to your general views and inside @Html.Partial("_displayCustomPartial") put @Html.Partial("_displayCustomPartial") . Then go back to the general views folder and create a new _displayCustomPartial view. Open _displayCustomPartial.cshtml and then use this code inside it:
@{ var controllerCalled = ViewContext.Controller.ValueProvider.GetValue("controller").RawValue; var actionCalled = ViewContext.Controller.ValueProvider.GetValue("action").RawValue; switch(controllerCalled){ case "Home": @Html.Partial("_homePartial"); break; case "Work": @Html.Partial("_workPartial"); break; case default:break; } }
This scenario assumes that ready-made views are ready for each controller script (I also included an action code if you want to use it). If the finished views are not ready, just enter the code that should be displayed for each case, and not to display a different view.
The main difference between this and the sections is that the sections share the model with their representation, and the use of partial representations would allow the inclusion of a separate model.
source share