I'm having problems with something that should be simple.
I have two use cases...
I want to do the same thing in either case except I don't want to use the layout for my website in the case it's the iframe so I have a "plain" layout
layout "plain"
How can I dynamically assign the layout depending on the case..
ie params[:iframe] == true
etc.
Nothing I do seems to work.
Yes, we can use multiple Layout in ASP.Net MVC application. By default, Visual Studio adds a Layout page in a shared folder which can be used by other View pages if required. In some cases, we can have the requirement to use multiple shared layout pages in MVC application.
We can also create multiple _ViewStart. cshtml pages. The file execution is dependent upon the location of the file within the folder hierarchy and the view being rendered. The MVC Runtime will first execute the code of the _ViewStart.
try this
layout :layout_by_resource
def layout_by_resource
if params[:iframe] == true
'plain'
else
"your-main-layout"
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With