WebX.ViewRenderer 1.0.1

dotnet add package WebX.ViewRenderer --version 1.0.1                
NuGet\Install-Package WebX.ViewRenderer -Version 1.0.1                
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="WebX.ViewRenderer" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WebX.ViewRenderer --version 1.0.1                
#r "nuget: WebX.ViewRenderer, 1.0.1"                
#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 WebX.ViewRenderer as a Cake Addin
#addin nuget:?package=WebX.ViewRenderer&version=1.0.1

// Install WebX.ViewRenderer as a Cake Tool
#tool nuget:?package=WebX.ViewRenderer&version=1.0.1                

WebX.ViewRender

Allows you to use razor syntax and generate views with viewmodels and returns a string result in runtime for use in email senders

Installation:

NuGet Package: | Description | Link | | ------ | ------ | | NuGet Page | https://www.nuget.org/packages/WebX.ViewRender/ | | Download NuGet Package | https://www.nuget.org/api/v2/package/WebX.ViewRender |

Usage:

// Step one: Create a partial view under Views folder

// Step two: In the Startup.cs, under ConfigureServices add this line in order to use dependancy injection

services.AddTransient<IPartialViewRenderer, PartialViewRenderer>();;

// Step three: In the Controller in which you want to use this view render add this field this line in order to use dependancy injection

private readonly IPartialViewRenderer _renderer;

// Step four: In the Controller constructor add this parameter to the constructor

IRazorPartialToStringRenderer renderer

// Step four: In the Controller constructor add this line to map the parameter to the field

_renderer = renderer;

// Step five: When you want to use the Render use the line specified below // In my case I passed the url(string) as a model to the view, but it can use any viewmodel in the conventional manner

string myHostUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}";

var url = $"{myHostUrl}/Account/ActivateEmployeeAccount?key={encodedKey}";

// THIS LINE
var body = await _renderer.RenderToStringAsync("EmailViews/_ActivateYourAccount", url);
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 469 10/3/2021