Skip to content

Commit 6438c2f

Browse files
authored
Add README to Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package (#54508)
1 parent 4ed0c2b commit 6438c2f

File tree

1 file changed

+83
-0
lines changed
  • src/Mvc/Mvc.Razor.RuntimeCompilation/src

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## About
2+
3+
Microsoft.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.
4+
5+
## Key Features
6+
7+
* Runtime compilation of Razor views in ASP.NET Core MVC applications.
8+
* Allows developers to modify Razor views without restarting the application.
9+
* Supports faster iteration and development cycles.
10+
* Compatible with ASP.NET Core 3.0 and newer.
11+
12+
## Limitations
13+
14+
* Isn't supported for Razor components of Blazor apps.
15+
* Doesn't support [global using directives](/dotnet/csharp/whats-new/csharp-10#global-using-directives).
16+
* Doesn't support [implicit using directives](/dotnet/core/tutorials/top-level-templates#implicit-using-directives).
17+
* Disables [.NET Hot Reload](xref:test/hot-reload).
18+
* Is recommended for development, not for production.
19+
20+
## How to Use
21+
22+
To start using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation in your ASP.NET Core MVC application, follow these steps:
23+
24+
### Installation
25+
26+
Install the package via NuGet Package Manager or .NET CLI:
27+
28+
```sh
29+
dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
30+
```
31+
32+
### Configuration
33+
34+
In your Startup.cs file, configure runtime compilation for Razor views:
35+
36+
```C#
37+
using Microsoft.AspNetCore.Mvc;
38+
using Microsoft.Extensions.DependencyInjection;
39+
40+
public void ConfigureServices(IServiceCollection services)
41+
{
42+
services.AddControllersWithViews()
43+
.AddRazorRuntimeCompilation();
44+
}
45+
```
46+
47+
### Usage
48+
Now, you can modify Razor views in your application, and the changes will be picked up dynamically without requiring a restart:
49+
50+
```html
51+
<!-- Example Razor view: Views/Home/Index.cshtml -->
52+
@{
53+
ViewData["Title"] = "Home Page";
54+
}
55+
56+
<h2>@ViewData["Title"]</h2>
57+
58+
<p>Welcome to the ASP.NET Core MVC application!</p>
59+
```
60+
61+
For more information on using runtime compilation for Razor views in ASP.NET Core MVC, refer to the [official documentation](https://learn.microsoft.com/en-us/aspnet/core/mvc/overview?view=aspnetcore-8.0).
62+
63+
## Main Types
64+
65+
<!-- The main types provided in this library -->
66+
67+
The main types provided by this library are:
68+
69+
* `RazorRuntimeCompilationMvcBuilderExtensions`: Extension methods for configuring runtime compilation for Razor views.
70+
* `RazorRuntimeCompilationMvcOptions`: Options for configuring runtime compilation settings.
71+
72+
## Additional Documentation
73+
74+
<!-- Links to further documentation. Remove conceptual documentation if not available for the library. -->
75+
76+
* [Overview of ASP.NET Core MVC](https://learn.microsoft.com/en-us/aspnet/core/mvc/overview?view=aspnetcore-8.0)
77+
* [Razor syntax reference for ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-8.0)
78+
79+
## Feedback & Contributing
80+
81+
<!-- How to provide feedback on this package and contribute to it -->
82+
83+
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation is released as open-source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/aspnetcore).

0 commit comments

Comments
 (0)