Razor:从嵌套的布局中创建视图不会自动创建部分。

时间:2022-03-10 21:12:26

I am happily converting to Razor. However, one irritating thing is that when creating a view, it doesn't add the sections for the selected layout (u2bka masterpages...).

我很高兴地变成了剃刀。然而,令人恼火的是,在创建视图时,它没有为所选的布局添加部分(u2bka主页…)。

Is this to be amended for RTM or is this it??

这是要修改RTM还是这个?

Either way, where (or to whom) do I whinge? It is an absolute pain putting in all the sections.

不管怎样,我该在哪里(或向谁)抱怨?把所有的部分都写进去是绝对痛苦的。

PS:

PS:

u2bka: Used to be known as.

u2bka:过去被称为。

2 个解决方案

#1


1  

The Add View dialog for the Razor view engine does not currently support this feature (and probably won't for MVC 3 RTM either). This is because of some fundamental differences between Aspx and Razor. Aspx is declarative which means it's a lot easier to parse in these scenarios. Razor is imperative which means it's a lot more difficult to detect all cases without actually running the page code (which we cannot do because it might have side effects).

Razor视图引擎的Add View对话框目前不支持这个特性(可能也不会支持MVC 3 RTM)。这是因为Aspx和Razor之间存在一些根本的差异。Aspx是声明性的,这意味着在这些场景中解析更容易。Razor是势在必行的,这意味着如果不实际运行页面代码就很难检测到所有情况(这是我们做不到的,因为它可能有副作用)。

But we could consider some heuristics for MVC 4.

但是我们可以考虑一些MVC 4的启发式。

#2


1  

I am not too sure in your case but I would strongly suggest you read Andrew's blog post on Razor's nested layouts. It really explains things.

我不太确定你的情况,但我强烈建议你阅读Andrew关于Razor嵌套布局的博客文章。真的解释了事情。

http://aboutcode.net/2010/11/08/nested-layout-pages-in-razor.html

http://aboutcode.net/2010/11/08/nested-layout-pages-in-razor.html

#1


1  

The Add View dialog for the Razor view engine does not currently support this feature (and probably won't for MVC 3 RTM either). This is because of some fundamental differences between Aspx and Razor. Aspx is declarative which means it's a lot easier to parse in these scenarios. Razor is imperative which means it's a lot more difficult to detect all cases without actually running the page code (which we cannot do because it might have side effects).

Razor视图引擎的Add View对话框目前不支持这个特性(可能也不会支持MVC 3 RTM)。这是因为Aspx和Razor之间存在一些根本的差异。Aspx是声明性的,这意味着在这些场景中解析更容易。Razor是势在必行的,这意味着如果不实际运行页面代码就很难检测到所有情况(这是我们做不到的,因为它可能有副作用)。

But we could consider some heuristics for MVC 4.

但是我们可以考虑一些MVC 4的启发式。

#2


1  

I am not too sure in your case but I would strongly suggest you read Andrew's blog post on Razor's nested layouts. It really explains things.

我不太确定你的情况,但我强烈建议你阅读Andrew关于Razor嵌套布局的博客文章。真的解释了事情。

http://aboutcode.net/2010/11/08/nested-layout-pages-in-razor.html

http://aboutcode.net/2010/11/08/nested-layout-pages-in-razor.html