Skip to content

Commit 0e69748

Browse files
Copilotgewarren
andcommitted
Add Razor runtime compilation obsolescence documentation for .NET 10
Co-authored-by: gewarren <[email protected]>
1 parent 818ce4b commit 0e69748

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
1515
> [!NOTE]
1616
> This article is a work in progress. It's not a complete list of breaking changes in .NET 10.
1717
18+
## ASP.NET Core
19+
20+
| Title | Type of change | Introduced version |
21+
|-------|---------------------|--------------------|
22+
| [Razor runtime compilation is obsolete](aspnet-core/10.0/razor-runtime-compilation-obsolete.md) | Source incompatible | Preview 7 |
23+
1824
## Containers
1925

2026
| Title | Type of change | Introduced version |
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: "Breaking change: Razor runtime compilation is obsolete"
3+
description: Learn about the breaking change in ASP.NET Core 10.0 where Razor runtime compilation APIs have been marked obsolete.
4+
ms.date: 08/08/2025
5+
---
6+
7+
# Razor runtime compilation is obsolete
8+
9+
Razor runtime compilation is obsolete and is not recommended for production scenarios. For production scenarios, use the default build time compilation. For development scenarios, use Hot Reload instead.
10+
11+
## Version introduced
12+
13+
.NET 10 Preview 7
14+
15+
## Previous behavior
16+
17+
Developers could use [Razor runtime compilation](/aspnet/core/mvc/views/view-compilation) to recompile `.cshtml` files while the application is running. This is useful for development time so you don't need to restart the application for changes to take effect.
18+
19+
## New behavior
20+
21+
Using the APIs listed below will produce a compiler warning with diagnostic ID `ASPDEPR003`:
22+
23+
> warning ASPDEPR003: Razor runtime compilation is obsolete and is not recommended for production scenarios. For production scenarios, use the default build time compilation. For development scenarios, use Hot Reload instead. For more information, visit <https://aka.ms/aspnet/deprecate/003>.
24+
25+
## Type of breaking change
26+
27+
This change affects [source compatibility](../../categories.md#source-compatibility).
28+
29+
## Reason for change
30+
31+
Razor Runtime compilation has been replaced by Hot Reload which has been the recommended approach for a few years now. This change makes it clearer that Razor Runtime compilation is not getting support for new features and should no longer be used.
32+
33+
## Recommended action
34+
35+
Remove calls to `.AddRazorRuntimeCompilation()` and use Hot Reload.
36+
37+
### Before
38+
39+
```csharp
40+
public void ConfigureServices(IServiceCollection services)
41+
{
42+
services.AddMvc()
43+
.AddRazorRuntimeCompilation();
44+
}
45+
```
46+
47+
### After
48+
49+
Remove the call to `AddRazorRuntimeCompilation()`:
50+
51+
```csharp
52+
public void ConfigureServices(IServiceCollection services)
53+
{
54+
services.AddMvc();
55+
}
56+
```
57+
58+
For development scenarios, use [Hot Reload](/dotnet/core/tools/dotnet-watch) instead:
59+
60+
```console
61+
dotnet watch
62+
```
63+
64+
## Affected APIs
65+
66+
- <xref:Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPartExtensions?displayProperty=fullName>
67+
- <xref:Microsoft.Extensions.DependencyInjection.RazorRuntimeCompilationMvcBuilderExtensions.AddRazorRuntimeCompilation%2A?displayProperty=fullName>
68+
- <xref:Microsoft.Extensions.DependencyInjection.RazorRuntimeCompilationMvcCoreBuilderExtensions.AddRazorRuntimeCompilation%2A?displayProperty=fullName>
69+
- <xref:Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.FileProviderRazorProjectItem?displayProperty=fullName>
70+
- <xref:Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.MvcRazorRuntimeCompilationOptions?displayProperty=fullName>

0 commit comments

Comments
 (0)