Razor.Templating.Core 1.3.0

Render your .cshtml files to string. Works out of the box for Web, Console, Worker Service, Desktop Apps in .NET Core.

There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package Razor.Templating.Core -Version 1.3.0
dotnet add package Razor.Templating.Core --version 1.3.0
<PackageReference Include="Razor.Templating.Core" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Razor.Templating.Core --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Razor Templating

Build+Test Nuget Downloads

Using Razor for HTML templating was never been so easy like this. Render your .cshtml files into string easily using this library.

This project makes use of Razor SDK for precompiling the views.

Supported Application Types

This library supports Console, Web Api, Mvc, Worker Service, WPF, WinForms on .NET Core 3.0, .NET Core 3.1, .NET 5

Applications

  • Email Templating
  • Report Generation & so on

Installing Nuget Package

This library is available as Nuget package

Using .NET CLI
dotnet add package Razor.Templating.Core
Using Package Reference .csproj
<PackageReference Include="Razor.Templating.Core" Version="1.3.0" />

Simple Usage:

using Razor.Templating.Core;

var model = new ExampleModel()
{
    PlainText = "This text is rendered from Razor Views using Razor.Templating.Core",
    HtmlContent = "<em>You can use it to generate email content, report generation and so on</em>"
};

var viewData = new Dictionary<string, object>();
viewData["Value1"] = "1";
viewData["Value2"] = "2";

var html = await RazorTemplateEngine.RenderAsync("/Views/ExampleView.cshtml", model, viewData);

Before applying this code, follow this article for working implementation: https://medium.com/@soundaranbu/render-razor-view-cshtml-to-string-in-net-core-7d125f32c79

Razor Views in Library

Razor view files(.cshtml) can be organized in a separate shared libary. Sample library can be found here

Sample Applications

Please find the sample applications here

Note:

  • Please ensure that the views path is always unique among all the shared template projects.
References:

Thanks to all the great articles and projects which helped to bring this library out!

  • https://github.com/Andy9FromSpace/razor-renderer-core
  • https://github.com/aspnet/Entropy/tree/master/samples/Mvc.RenderViewToString
  • https://www.frakkingsweet.com/razor-template-rendering/
  • https://github.com/veccsolutions/RenderRazorConsole
  • https://emilol.com/razor-mailer/
  • https://codeopinion.com/using-razor-in-a-console-application/

Razor Templating

Build+Test Nuget Downloads

Using Razor for HTML templating was never been so easy like this. Render your .cshtml files into string easily using this library.

This project makes use of Razor SDK for precompiling the views.

Supported Application Types

This library supports Console, Web Api, Mvc, Worker Service, WPF, WinForms on .NET Core 3.0, .NET Core 3.1, .NET 5

Applications

  • Email Templating
  • Report Generation & so on

Installing Nuget Package

This library is available as Nuget package

Using .NET CLI
dotnet add package Razor.Templating.Core
Using Package Reference .csproj
<PackageReference Include="Razor.Templating.Core" Version="1.3.0" />

Simple Usage:

using Razor.Templating.Core;

var model = new ExampleModel()
{
    PlainText = "This text is rendered from Razor Views using Razor.Templating.Core",
    HtmlContent = "<em>You can use it to generate email content, report generation and so on</em>"
};

var viewData = new Dictionary<string, object>();
viewData["Value1"] = "1";
viewData["Value2"] = "2";

var html = await RazorTemplateEngine.RenderAsync("/Views/ExampleView.cshtml", model, viewData);

Before applying this code, follow this article for working implementation: https://medium.com/@soundaranbu/render-razor-view-cshtml-to-string-in-net-core-7d125f32c79

Razor Views in Library

Razor view files(.cshtml) can be organized in a separate shared libary. Sample library can be found here

Sample Applications

Please find the sample applications here

Note:

  • Please ensure that the views path is always unique among all the shared template projects.
References:

Thanks to all the great articles and projects which helped to bring this library out!

  • https://github.com/Andy9FromSpace/razor-renderer-core
  • https://github.com/aspnet/Entropy/tree/master/samples/Mvc.RenderViewToString
  • https://www.frakkingsweet.com/razor-template-rendering/
  • https://github.com/veccsolutions/RenderRazorConsole
  • https://emilol.com/razor-mailer/
  • https://codeopinion.com/using-razor-in-a-console-application/

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Razor.Templating.Core:

Package Downloads
Dotented
Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.4.0-rc.1 55 11/19/2020
1.3.0 511 11/17/2020
1.2.1 4,031 9/21/2020
1.2.0 1,659 7/11/2020
1.1.2 553 4/13/2020
1.1.0 124 4/13/2020
1.0.1 141 4/3/2020
1.0.0 154 4/3/2020