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
2
Answers
In this case, we can set it in _ViewStart file using ViewData.
You could find the difference of ViewResult between asp.net and asp.net core
Asp.Net Core
Asp.Net
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: