在ASP.NET 5 MVC6中代替WebViewPage.RenderPage方法使用的内容 [英] What to use instead of WebViewPage.RenderPage method in ASP.NET 5 MVC6
问题描述
给出一个基于旧MVC5的示例: Views/Shared/Index.cshtml-SPA应用程序的视图.它包含一些标记和对布局页面的引用:
Given an example based on old MVC5: Views/Shared/Index.cshtml - a view for a SPA app. It contains some markup and a reference to a layout-page:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
在_Layout.cshtml中,有许多包含项通过RenderPage
帮助器使用:
In _Layout.cshtml there're number of includes which are being used via RenderPage
helper:
@RenderPage("~/Views/Shared/_ImportCssInline.cshtml")
@RenderPage("~/Views/Shared/_ImportCssLinks.cshtml")
AspNet5 @RenderPage
助手中的现在不可用.
是WebViewPage
/WebPageBase
/WebPageRenderingBase
的方法.现在将它们替换为RazorPage
.但是其中没有RenderPage
方法.
Now in AspNet5 @RenderPage
helper isn't available.
It was the method of WebViewPage
/WebPageBase
/WebPageRenderingBase
. Now they were replaced by RazorPage
. But there's no RenderPage
method in it.
应该用什么代替?
p.s. 问题
推荐答案
我一直成功使用@Html.Partial("~/Views/Shared/_ImportCssInline.cshtml")
而不是@RenderPage
-我希望您的用法没有差异.这些导入现在也有异步版本.
I've always had success using @Html.Partial("~/Views/Shared/_ImportCssInline.cshtml")
rather than @RenderPage
- I hope there's not usage differences for you. There are also async versions of these imports now, too.
由于Html
属性现在可以作为接口IHtmlHelper
注入,因此我认为在改进视图的可测试性方面,直接方法已被删除.
Since the Html
property is now injectable as the interface IHtmlHelper
, I assume the direct methods were removed in the improvements for the testability of the views.
这篇关于在ASP.NET 5 MVC6中代替WebViewPage.RenderPage方法使用的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!