Developer forum

Forum » Development » Master layout in code first approach

Master layout in code first approach

Kien Tran
Reply

Hi,

I tried to get start the development with code first approach. Following your video here: https://vimeo.com/217447832. I have defined a master page for my website (Using administrator tool of Dynamicweb), it is applied for all pages. But it was not applicable for my custom Customer/Index.cshtml views.

My question was somehow we can manually get the pre-defined layout in Dynamicweb, then set it to my custom .cshtml views? Please see attched files for more detail.

Thanks in advance

 

customer_index.png

Replies

 
Kien Tran
Reply

Hi Nicolai,

Base upon your answer via email, it seems that this is impossible because the Customer/Index.cshtml was beyond Dynamicweb's template engine.

In this case, I tried to define a Master layout inside ~/Views/Shared/_Layout.cshtml, then manually set the Layout property of Customer/Index.cshtml to that file. Now I got an exception of empty Context property. If I set the Layout property to null, it works well.

Is there any solution to work around? or Was I missed anything?

Please have a look at the attached picture.

empty_context.png
 
Nicolai Pedersen
Reply

I think I need to see the entire stack of that exception and would also like to see your index.cshtml and _layout.cshtml

But you are not dealing with Dynamicweb at all in this setup, so it seems to be a MVC related issue.

 

You must be logged in to post in the forum