Aspnetcore: Using Razor standalone in DotNet Core 3.0

Created on 30 Sep 2019  路  4Comments  路  Source: dotnet/aspnetcore

_From @genifycom on Saturday, September 28, 2019 3:37:25 AM_

Issue Title

Now that we have separate invocations for MapRazorPages(), is it possible in DotNet Core 3.0 to create a console app that calls the Razor engine to create a page?

Are there any samples of this in DotNet Core 3.0?

General

Calling the Razor engine without requiring routing, MVC etc is extremely use for reporting and a number of other scenarios. This has been frustratingly close in prior DotNet Core versions. With DotNet Core 3.0 several parts of the framework have been separated out and it would seem that it might be possible now to use Razor pages standalone.

Could someone on the team please help with a sample on how to do this?

_Copied from original issue: dotnet/core#3498_

area-mvc

Most helpful comment

It is, indeed, a very important scenario to cover.

There are a number of open-source projets out there for .NET templating. Including RazorLight, which uses the ASP.NET Core Razor librairies under the hood, but hasn't been actively maintained in recent times.

A Microsoft-maintained solution would be a very convincing addition to the ASP.NET Core platform.

All 4 comments

_From @genifycom on Saturday, September 28, 2019 3:53:15 AM_

Is there something like RazorViewToStringRenderer for DotNet Core 3.0?

It is, indeed, a very important scenario to cover.

There are a number of open-source projets out there for .NET templating. Including RazorLight, which uses the ASP.NET Core Razor librairies under the hood, but hasn't been actively maintained in recent times.

A Microsoft-maintained solution would be a very convincing addition to the ASP.NET Core platform.

Thanks for the issue report. The sample in https://github.com/aspnet/Entropy/tree/7a53120c620bbcfd7b54f147c16fa7da1e38d1d4/samples/Mvc.RenderViewToString should continue to work in .NET Core 3.0. We currently do not have any plans of adding a general purpose templating engine that works outside of the ASP.NET Core pipeline.

@pranavkm , it does not work between assemblies actually. #15046

Was this page helpful?
0 / 5 - 0 ratings