MVC 3 razor layout

2019-02-16 09:26发布

I have a MVC 3 project in which I use _Layout.cshtml as master page in all web pages. Now I want to remove this master page (layout) from one of the page (progress.cshtml). So I removed the removed the top portion of the page which was

@{
    ViewBag.Title = "Progress";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

I thought this will work but when I browse progress page it still shows the content from layout file. How I can remove this binding?

3条回答
Bombasti
2楼-- · 2019-02-16 09:38

the issue is there is a file named _viewstart.cshtml which behave as the config file to know the engine which is the masterfile.

For more info have a look:

http://weblogs.asp.net/gunnarpeipman/archive/2010/10/10/asp-net-mvc-3-beta-view-start-files-for-razor-view-engine.aspx

Thanks

查看更多
\"骚年 ilove
3楼-- · 2019-02-16 09:42

Set the layout= null to remove the default layout inheritance in that view

查看更多
甜甜的少女心
4楼-- · 2019-02-16 09:59
@{
ViewBag.Title = "Progress";
Layout = null;
}
查看更多
登录 后发表回答