IL.VirtualViews
1.7.0
See the version list below for details.
dotnet add package IL.VirtualViews --version 1.7.0
NuGet\Install-Package IL.VirtualViews -Version 1.7.0
<PackageReference Include="IL.VirtualViews" Version="1.7.0" />
<PackageVersion Include="IL.VirtualViews" Version="1.7.0" />
<PackageReference Include="IL.VirtualViews" />
paket add IL.VirtualViews --version 1.7.0
#r "nuget: IL.VirtualViews, 1.7.0"
#:package IL.VirtualViews@1.7.0
#addin nuget:?package=IL.VirtualViews&version=1.7.0
#tool nuget:?package=IL.VirtualViews&version=1.7.0
IL.VirtualViews
Library which allows virtually register *.cshtml file as .cs classes with special attributes.
How to use
- Reference IL.VirtualViews in your project
- Use registration extensions coming with library to activate functionality:
(IServiceCollection)services.AddVirtualViewsCapabilities()or(WebApplicationBuilder)builder.AddVirtualViewsCapabilities() - Use
[VirtualViewPath("")]attribute for your classes with path to a view you want to register virtually - Derive your class from
IVirtualViewinterface and implement the content which view is supposed to have
Examples
[VirtualViewPath("/Views/Test.cshtml")]
class Sample : IVirtualView
{
public static string ViewContent =>
"""
@model string
@Html.Raw(Model)
""";
}
Virtual cshtml
There a support for .virtual.cshtml files that have build action Additional Files.
Following location of such file there will be generated partial *.cs file with same name as source *.virtual.cshtml file.
Autogenerated file will automatically have all the content that you have populated in .virtual.cshtml, so that you can only introduce your own(not source generated) partial part and decorate it with VirtualViewPath attribute.
Sample
/Test/Test.virtual.cshtml addded to solution with build action = Additional Files
and with content
@model string
@Html.Raw(Model)
will produce source generated file Test.g.cs:
using IL.VirtualViews.Interfaces;
namespace VirtualViews;
public partial class Test : IVirtualView
{
public static string ViewContent =>
"""
@model string
@Html.Raw(Model)
""";
}
Then you only need to create non-auto-generated partial part and decorate it with VirtualViewPath attribute with desired path original view was supposed to be handled for.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- IL.Misc (>= 1.3.1)
- Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (>= 8.0.14)
-
net9.0
- IL.Misc (>= 1.3.1)
- Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (>= 9.0.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on IL.VirtualViews:
| Package | Downloads |
|---|---|
|
IL.RulesBasedOutputCache
Rules based output cache. |
|
|
IL.AttributeBasedDI.Visualizer
Extension for IL.AttributeBasedDI |
GitHub repositories
This package is not used by any popular GitHub repositories.