IL.VirtualViews
1.9.2.3
dotnet add package IL.VirtualViews --version 1.9.2.3
NuGet\Install-Package IL.VirtualViews -Version 1.9.2.3
<PackageReference Include="IL.VirtualViews" Version="1.9.2.3" />
<PackageVersion Include="IL.VirtualViews" Version="1.9.2.3" />
<PackageReference Include="IL.VirtualViews" />
paket add IL.VirtualViews --version 1.9.2.3
#r "nuget: IL.VirtualViews, 1.9.2.3"
#:package IL.VirtualViews@1.9.2.3
#addin nuget:?package=IL.VirtualViews&version=1.9.2.3
#tool nuget:?package=IL.VirtualViews&version=1.9.2.3
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.
Registration behavior
When source generation is enabled, the package now also generates IL.VirtualViews.Generated.VirtualViewRegistry in your project.
AddVirtualViewsCapabilities(...) uses this generated registry first, so virtual view discovery is compile-time driven instead of assembly-wide runtime scanning.
If no generated registry is present for an assembly, the previous reflection-based fallback is still used.
Debugging virtual views
By default, debug physical files are controlled by configuration key VirtualViews:Debug (true/false).
When enabled, virtual view content is mirrored to temporary physical files and exposed through IFileInfo.PhysicalPath.
This improves Razor diagnostics and makes virtual views easier to debug.
Example configuration:
{
"VirtualViews": {
"Debug": true
}
}
You can still explicitly override this behavior in code:
services.AddVirtualViewsCapabilities(
options => options.EnableDebugPhysicalFiles = true,
"*"
);
or
builder.AddVirtualViewsCapabilities(
options => options.EnableDebugPhysicalFiles = true,
"*"
);
| 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 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
- IL.Misc (>= 1.5.1.2)
- Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (>= 10.0.0 && < 11.0.0)
-
net8.0
- IL.Misc (>= 1.5.1.2)
- Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (>= 8.0.0 && < 9.0.0)
-
net9.0
- IL.Misc (>= 1.5.1.2)
- Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (>= 9.0.0 && < 10.0.0)
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.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.9.2.3 | 0 | 5/4/2026 | |
| 1.9.2.2 | 0 | 5/4/2026 | |
| 1.9.2.1 | 42 | 5/3/2026 | |
| 1.9.1.1 | 194 | 3/20/2026 | |
| 1.9.0.3 | 188 | 1/21/2026 | |
| 1.9.0.2 | 443 | 1/5/2026 | |
| 1.9.0.1 | 112 | 1/5/2026 | |
| 1.8.0 | 542 | 10/30/2025 | |
| 1.7.0 | 1,735 | 4/8/2025 | |
| 1.6.1 | 1,792 | 12/1/2024 | |
| 1.6.0 | 160 | 12/1/2024 | |
| 1.5.0 | 683 | 9/15/2024 | |
| 1.4.0 | 225 | 9/13/2024 | |
| 1.3.2 | 199 | 9/13/2024 | |
| 1.3.1 | 197 | 9/11/2024 | |
| 1.3.0 | 213 | 8/10/2024 | |
| 1.2.1 | 436 | 7/15/2024 | |
| 1.2.0 | 177 | 7/15/2024 |