GravySoft.Razor.StringGenerator.NetFramework
1.0.0
dotnet add package GravySoft.Razor.StringGenerator.NetFramework --version 1.0.0
NuGet\Install-Package GravySoft.Razor.StringGenerator.NetFramework -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GravySoft.Razor.StringGenerator.NetFramework" 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.NetFramework --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.NetFramework, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GravySoft.Razor.StringGenerator.NetFramework as a Cake Addin #addin nuget:?package=GravySoft.Razor.StringGenerator.NetFramework&version=1.0.0 // Install GravySoft.Razor.StringGenerator.NetFramework as a Cake Tool #tool nuget:?package=GravySoft.Razor.StringGenerator.NetFramework&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GravySoft.Razor.StringGenerator
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.
Usage
- Inject an
IRazorViewToStringRenderer
to your class.
private IRazorViewToStringRenderer renderer;
public ExampleClass(IRazorViewToStringRenderer renderer) => this.renderer = renderer;
- 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
Bind<RazorViewToStringRenderer>().To<IRazorViewToStringRenderer>();
Changelog
1.0.0
- Initial Release
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- GravySoft.Razor.StringGenerator (>= 1.0.0)
- Microsoft.AspNet.Mvc (>= 5.0.0)
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 |
---|---|---|
1.0.0 | 608 | 8/21/2019 |