ch1seL.RazorViewRender 6.0.0

Install-Package ch1seL.RazorViewRender -Version 6.0.0
dotnet add package ch1seL.RazorViewRender --version 6.0.0
<PackageReference Include="ch1seL.RazorViewRender" Version="6.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ch1seL.RazorViewRender --version 6.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ch1seL.RazorViewRender, 6.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 ch1seL.RazorViewRender as a Cake Addin
#addin nuget:?package=ch1seL.RazorViewRender&version=6.0.0

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

Build Test Publish


Easy way to render Razor View to string. It might be use to compose mail message or other texts through Razor Views.

How to use


Nuget Package Manager Console:
Install-Package ch1seL.RazorViewRenderService
.Net CLI:
dotnet add package ch1seL.RazorViewRenderService

Sample using

Create blank ASP.NET Core Web Application MVC:

dotnet new mvc -n RazorViewRender.Sample

Install Nuget package

dotnet add package ch1seL.RazorViewRenderService

Update Startup.cs:

using ch1seL.RazorViewRender;
        public void ConfigureServices(IServiceCollection services)

Add template model class Models/FooBarModel.cs

namespace RazorViewRender.Sample.Models
        public class FooBarModel
                public string Foo { get; set; }
                public string Bar { get; set; }

Add razor template Views/Home/FooBar.cshtml

@model RazorViewRender.Sample.Models.FooBarModel

<!DOCTYPE html>


Update Controllers/HomeController.cs Add RazorViewRenderService as DI Add FooBar method to compose html-string content

using ch1seL.RazorViewRender;
        private readonly RazorViewRenderService _razorViewRenderService;

        public HomeController(ILogger<HomeController> logger, RazorViewRenderService razorViewRenderService)
            _logger = logger;
            _razorViewRenderService = razorViewRenderService;

        public async Task<IActionResult> FooBar()
            var content = await _razorViewRenderService.RenderStringAsync("Home/FooBar",
                new FooBarModel
                    Foo = "Foo", 
                    Bar = "<b>B</b>ar"

            return new ContentResult()
                Content = content,
                ContentType = "text/html",
                StatusCode = 200

Run application

dotnet run 

Open site https://localhost:5001/Home/FooBar to get result

  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.0 61 11/17/2021 550 11/10/2020 173 11/10/2020 234 11/10/2020
5.0.0 145 11/10/2020
3.1.0 321 1/10/2020