Runtime compilation support for Razor views and Razor Pages in ASP.NET Core MVC. This package was built from the source code at https://github.com/dotnet/dotnet/tree/87bc0b04e21d786669142109a5128c95618b75ed
$ dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilationMicrosoft.AspNetCore.Mvc.Razor.RuntimeCompilation is a NuGet package designed to provide runtime compilation support for Razor views in ASP.NET Core MVC applications. This package enables developers to modify and update Razor views without needing to restart the application, facilitating a more dynamic development experience.
To start using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation in your ASP.NET Core MVC application, follow these steps:
Install the package via NuGet Package Manager or .NET CLI:
dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
In your Startup.cs file, configure runtime compilation for Razor views:
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews()
.AddRazorRuntimeCompilation();
}
Now, you can modify Razor views in your application, and the changes will be picked up dynamically without requiring a restart:
<!-- Example Razor view: Views/Home/Index.cshtml -->
@{
ViewData["Title"] = "Home Page";
}
<h2>@ViewData["Title"]</h2>
<p>Welcome to the ASP.NET Core MVC application!</p>
For more information on using runtime compilation for Razor views in ASP.NET Core MVC, refer to the official documentation.
The main types provided by this library are:
RazorRuntimeCompilationMvcBuilderExtensions: Extension methods for configuring runtime compilation for Razor views.RazorRuntimeCompilationMvcOptions: Options for configuring runtime compilation settings.Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.