与ASPX页面名为.master的Razor视图可能吗? [英] Is Razor view with ASPX .Master page possible?
问题描述
是否有可能保持我现有的.master页面,并将它与一个新的ASP.NET MVC 3剃须刀视图中使用?我想这样的:
Is it possible to keep my existing .master page and have it used with a new ASP.NET MVC 3 Razor view? I tried this:
@{
LayoutPage = "~/Views/Shared/Site.master";
}
和它给了我这个错误消息:
And it gives me this error message:
文件'〜/查看/共享/ Site.master母'不能被渲染,因为它不存在或不是有效的页面。
The file '~/Views/Shared/Site.master' could not be rendered, because it does not exist or is not a valid page.
推荐答案
可惜没有。母版页是ASPX的WebForms视图引擎的一部分,而不是MVC框架,剃须刀无法与之进行互操作。
Unfortunately no. Master pages are a part of the ASPX WebForms view engine, not the MVC framework so Razor cannot interoperate with it.
一个办法是复制的主人,正如你所说,但不是复制所有code,你可以因素的母版页成一束ASPX谐音的剃刀和ASPX主人可以嵌入的。然后就可以开始每一页和局部的,一个接一个,转换成剃刀,并最终摆脱ASPX高手。
One option would be to duplicate the masters, as you mentioned, but rather than copying all the code, you could factor the Master page into a bunch of ASPX partials that the Razor and ASPX masters could embed. Then you can start converting each page and partial, one-by-one, to Razor and eventually get rid of the ASPX master.
这篇关于与ASPX页面名为.master的Razor视图可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!