ApricotFramework.RazorEngine.AspNetCore
0.1.0
Prefix Reserved
dotnet add package ApricotFramework.RazorEngine.AspNetCore --version 0.1.0
NuGet\Install-Package ApricotFramework.RazorEngine.AspNetCore -Version 0.1.0
<PackageReference Include="ApricotFramework.RazorEngine.AspNetCore" Version="0.1.0" />
<PackageVersion Include="ApricotFramework.RazorEngine.AspNetCore" Version="0.1.0" />
<PackageReference Include="ApricotFramework.RazorEngine.AspNetCore" />
paket add ApricotFramework.RazorEngine.AspNetCore --version 0.1.0
#r "nuget: ApricotFramework.RazorEngine.AspNetCore, 0.1.0"
#:package ApricotFramework.RazorEngine.AspNetCore@0.1.0
#addin nuget:?package=ApricotFramework.RazorEngine.AspNetCore&version=0.1.0
#tool nuget:?package=ApricotFramework.RazorEngine.AspNetCore&version=0.1.0
ApricotFramework.RazorEngine.AspNetCore
Renders a Razor view to a string instead of to the response, so templated markup can be produced where there is no response to write to — an e-mail body, the input to a PDF converter, a background job.
Install
dotnet add package ApricotFramework.RazorEngine.AspNetCore
Usage
using ApricotFramework.RazorEngine.AspNetCore.Extensions;
// The only call needed. No AddControllersWithViews, no AddRazorPages.
builder.Services.AddRazorEngine();
using ApricotFramework.RazorEngine.AspNetCore;
public sealed class WelcomeMailer(IRazorEngine razorEngine)
{
public Task<string> BuildBodyAsync(Customer customer, CancellationToken cancellationToken)
{
return razorEngine.RenderAsync("~/Templates/Welcome.cshtml", customer, cancellationToken);
}
}
Address a template by path — ~/Templates/Welcome.cshtml — and it is found wherever it lives. A
bare view name goes through the view engine's conventions instead, and because there is no
controller route value to fill in, the only one reachable is /Views/Shared/{name}.cshtml. When
nothing matches, the InvalidOperationException lists every location that was searched.
Each render gets its own service scope, which is what lets the engine run with no request in flight — and also means a view resolving a scoped service during a request does not share that request's instance.
Full documentation: https://projectapricot.dev
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.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 |
|---|---|---|
| 0.1.0 | 182 | 8/14/2026 |