GravySoft.Razor.StringGenerator 1.0.0

Install-Package GravySoft.Razor.StringGenerator -Version 1.0.0
dotnet add package GravySoft.Razor.StringGenerator --version 1.0.0
<PackageReference Include="GravySoft.Razor.StringGenerator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GravySoft.Razor.StringGenerator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GravySoft.Razor.StringGenerator, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install GravySoft.Razor.StringGenerator as a Cake Addin
#addin nuget:?package=GravySoft.Razor.StringGenerator&version=1.0.0

// Install GravySoft.Razor.StringGenerator as a Cake Tool
#tool nuget:?package=GravySoft.Razor.StringGenerator&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

GravySoft.Razor.StringGenerator NuGet Logo

Service for rendering Razor MVC views to strings. This can be used for sending emails, generating PDFs, and any number of things.

You must also install either GravySoft.Razor.StringGenerator.AspNetCore or GravySoft.Razor.StringGenerator.NetFramework.


  1. Inject an IRazorViewToStringRenderer to your class.
private IRazorViewToStringRenderer renderer;
public ExampleClass(IRazorViewToStringRenderer renderer) => this.renderer = renderer;
  1. Execute your call.
string text = await renderer.RenderViewToStringAsync("~/Views/Email.cshtml", new EmailModel
    FirstName = "John",
    LastName = "Doe",
    FavoriteColors = new List<string> { "Red", "Purple", "Orange" }

Make sure you use the full path of the view

Registering Services

The service needs to be registered in as scoped so that it has access to a request HttpContext.

Microsoft Dependency Injection (.NET Core & Standalone .NET Framework)

In Startup.ConfigureServices

services.AddScoped<IRazorViewToStringRenderer, RazorViewToStringRenderer>();
Ninject (Sitefinity)

In your NinjectModule




  • Initial Release
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on GravySoft.Razor.StringGenerator:

Package Downloads

Render Razor views to strings in ASP.NET Core


Render Razor views to strings in ASP.NET

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 580 8/21/2019