1

Currently, I am upgrading .NET MVC to .NET Core MVC. In MVC we are using a method like below so I need to keep that logic and it's used in lots of places. so can you help to find a way to set the Layout page from .NET Core Controller?

return View ("NameOfView",masterName:"viewName"); How to set layout from controller

Rohit Patel
  • 201
  • 3
  • 8

2 Answers2

0

You could find the difference of ViewResult between asp.net and asp.net core Asp.Net Core enter image description here Asp.Net enter image description here

enter image description here

enter image description here there's no method supplied for your to set layout in controller the sameway with which you set masterpage in asp.net controller

You could set masterpage in your view Like:

@{
    Layout = "_myLayoutPage";
}
Ruikai Feng
  • 6,823
  • 1
  • 2
  • 11
0

In this case, we can set it in _ViewStart file using ViewData.

enter image description here

Rohit Patel
  • 201
  • 3
  • 8