0

I have created a view that should act as a master page(_MasterAccount.cshtml) with the following code:

<h1>TEST!!!!</h1>
@RenderBody()
<h1>TEST!!!!</h1>

I tried to have another view reference it using the following code:

@{ 
   ViewBag.Title = "My account - Options";
   Layout = "~/Views/Shared/_MasterAccount.cshtml";
 }

I am using RAZOR and there isn't a _viewstart.cshtml in the project

For some reason the layout is being ignored. It doesn't even throw an exception when I put in a non existing path.

Please note that there is already a "main" master page and mine is acting as a nested master page for specific set of pages.

The site has been developed by someone else, so I am suspecting that there is a piece of code that is overloading the layout property somehow. Thing is, I don't know where to look.

Please let me know if additional information is required.

Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70
Drahcir
  • 12,311
  • 19
  • 63
  • 76

1 Answers1

0

Found the solution in 2 answers from stack overflow.

A view engine was implemented in the system to locate the master pages, therefore the layout field was being ingored. As per this answer.

Therefore to implement the master within the master I opted for this solution although it looks a bit messy.

Community
  • 1
  • 1
Drahcir
  • 12,311
  • 19
  • 63
  • 76