Skip to content

Commit 5cf4631

Browse files
authored
Document Razor runtime compilation obsolescence in .NET 10 (#47898)
1 parent fc8e051 commit 5cf4631

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

docs/core/compatibility/10.0.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
1717
1818
## ASP.NET Core
1919

20-
| Title | Type of change | Introduced version |
21-
|-------|-------------------|--------------------|
20+
| Title | Type of change | Introduced version |
21+
|-------|---------------------|--------------------|
2222
| [Deprecation of WithOpenApi extension method](aspnet-core/10/withopenapi-deprecated.md) | Source incompatible | Preview 7 |
2323
| [IActionContextAccessor and ActionContextAccessor are obsolete](aspnet-core/10/iactioncontextaccessor-obsolete.md) | Source incompatible/behavioral change | Preview 7 |
2424
| [IncludeOpenAPIAnalyzers property and MVC API analyzers are deprecated](aspnet-core/10/openapi-analyzers-deprecated.md) | Source incompatible | Preview 7 |
2525
| [Microsoft.Extensions.ApiDescription.Client package deprecated](aspnet-core/10/apidescription-client-deprecated.md) | Source incompatible | Preview 7 |
26+
| [Razor run-time compilation is obsolete](aspnet-core/10/razor-runtime-compilation-obsolete.md) | Source incompatible | Preview 7 |
2627

2728
## Containers
2829

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: "Breaking change: Razor run-time compilation is obsolete"
3+
description: Learn about the breaking change in ASP.NET Core 10.0 where Razor run-time compilation APIs have been marked obsolete.
4+
ms.date: 08/08/2025
5+
---
6+
7+
# Razor run-time compilation is obsolete
8+
9+
Razor run-time 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+
Previously, you could use [Razor run-time compilation](/aspnet/core/mvc/views/view-compilation) to recompile `.cshtml` files while the application was running. This meant you didn't need to restart the application for changes to take effect.
18+
19+
## New behavior
20+
21+
Starting in .NET 10, use of the [affected APIs](#affected-apis) produces a compiler warning with diagnostic ID `ASPDEPR003`:
22+
23+
> warning ASPDEPR003: Razor run-time 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 can affect [source compatibility](../../categories.md#source-compatibility).
28+
29+
## Reason for change
30+
31+
Razor run-time 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 run-time compilation doesn't get support for new features and should no longer be used.
32+
33+
## Recommended action
34+
35+
Remove calls to <xref:Microsoft.Extensions.DependencyInjection.RazorRuntimeCompilationMvcBuilderExtensions.AddRazorRuntimeCompilation%2A> and use Hot Reload instead.
36+
37+
## Affected APIs
38+
39+
- <xref:Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPartExtensions?displayProperty=fullName>
40+
- <xref:Microsoft.Extensions.DependencyInjection.RazorRuntimeCompilationMvcBuilderExtensions.AddRazorRuntimeCompilation%2A?displayProperty=fullName>
41+
- <xref:Microsoft.Extensions.DependencyInjection.RazorRuntimeCompilationMvcCoreBuilderExtensions.AddRazorRuntimeCompilation%2A?displayProperty=fullName>
42+
- <xref:Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.FileProviderRazorProjectItem?displayProperty=fullName>
43+
- <xref:Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.MvcRazorRuntimeCompilationOptions?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ items:
1818
href: aspnet-core/10/openapi-analyzers-deprecated.md
1919
- name: Microsoft.Extensions.ApiDescription.Client package deprecated
2020
href: aspnet-core/10/apidescription-client-deprecated.md
21+
- name: Razor run-time compilation is obsolete
22+
href: aspnet-core/10/razor-runtime-compilation-obsolete.md
2123
- name: Containers
2224
items:
2325
- name: Default .NET images use Ubuntu

0 commit comments

Comments
 (0)