Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to use instead of WebViewPage.RenderPage method in ASP.NET 5 MVC6

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";
}

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")

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.

What should be used instead?

p.s. issue

like image 216
Shrike Avatar asked Apr 21 '15 10:04

Shrike


1 Answers

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.

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.

like image 184
Matt DeKrey Avatar answered Oct 01 '22 03:10

Matt DeKrey