Is it possible to suppress the layout expressed in _ViewStart.cshtml
using ASP.NET MVC 3 for certain views of an app.
对于应用程序的某些视图,是否可以使用ASP.NET MVC 3来抑制_ViewStart.cshtml中表达的布局。
I understand that I can define the layout programmatically in the controller action. Maybe passing in ""
achieves that?
我知道我可以在控制器动作中以编程方式定义布局。也许传入“”实现了这一点?
2 个解决方案
#1
22
You have two options
你有两个选择
1) Use return PartialView()
from controller, it won't take Layout from View start
1)使用从控制器返回PartialView(),它不会从View开始接受布局
2) Assign Layout = null,
2)分配Layout = null,
@{
Layout = null;
}
Check-out this interesting discussion and answer by marcind around this subject
看看这个有趣的讨论,并由marcind围绕这个主题回答
#2
2
In order not to apply a layout, just assign null to the Layout property in your view:
为了不应用布局,只需将null赋给视图中的Layout属性:
@{
Layout = null;
}
<!DOCTYPE html>
...
#1
22
You have two options
你有两个选择
1) Use return PartialView()
from controller, it won't take Layout from View start
1)使用从控制器返回PartialView(),它不会从View开始接受布局
2) Assign Layout = null,
2)分配Layout = null,
@{
Layout = null;
}
Check-out this interesting discussion and answer by marcind around this subject
看看这个有趣的讨论,并由marcind围绕这个主题回答
#2
2
In order not to apply a layout, just assign null to the Layout property in your view:
为了不应用布局,只需将null赋给视图中的Layout属性:
@{
Layout = null;
}
<!DOCTYPE html>
...