Skip to content

Commit fa557b3

Browse files
committed
add proxy guidance
1 parent b000cec commit fa557b3

3 files changed

Lines changed: 56 additions & 5 deletions

File tree

aspnetcore/migration/fx-to-core/areas/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ uid: migration/fx-to-core/areas
88
---
99
# Technology specific guidance
1010

11+
* [Authentication](authentication.md)
12+
* [ClaimsPrincipal.Current](claimsprincipal-current.md)
1113
* [HttpContext](http-context.md)
1214
* [HTTP Handlers](http-handlers.md)
1315
* [HTTP Modules](http-modules.md)
1416
* [Membership](membership.md)
17+
* [Miscellaneous](misc.md)
18+
* [Session State](session.md)
1519
* [WebAPI](webapi.md)
16-
* [ClaimsPrincipal.Current](claimsprincipal-current.md)
1720

1821
## Getting help
1922

aspnetcore/migration/fx-to-core/inc/remote-app-setup.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In some incremental upgrade scenarios, it's useful for the new ASP.NET Core app
1515

1616
Common scenarios this enables:
1717

18-
* Fallback to the legacy application with YARP
18+
* Fallback to the legacy application with [YARP](xref:fundamentals/servers/yarp/yarp-overview)
1919
* [Remote app authentication](xref:migration/fx-to-core/areas/authentication#remote-authenticationn)
2020
* [Remote session](xref:migration/fx-to-core/areas/session#remote-app-session-state)
2121

@@ -35,14 +35,14 @@ You need to configure two configuration values in both applications:
3535

3636
### ASP.NET Framework
3737

38+
> [!IMPORTANT]
39+
> The ASP.NET Framework application should be hosted with SSL enabled. In the remote app setup for incremental migration, it is not required to have direct access externally. It is recommended to only allow access from the client application via the proxy.
40+
3841
For ASP.NET Framework applications, add these values to your `web.config` in the `<appSettings>` section:
3942

4043
> [!IMPORTANT]
4144
> ASP.NET Framework stores its appSettings in `web.config`. However, they can be retrieved from other sources (such as environment variables) with the use of [configuration Builders](/aspnet/config-builder). This makes sharing configuration values much easier between the local and remote applications in this setup.
4245
43-
> [!IMPORTANT]
44-
> The ASP.NET Framework application should be hosted with SSL enabled. In the remote app setup for incremental migration, it is not required to have direct access externally. It is recommended to only allow access from the client application via the proxy.
45-
4646
```xml
4747
<appSettings>
4848
<add key="RemoteAppApiKey" value="..." />
@@ -104,3 +104,49 @@ builder.Services.AddSystemWebAdapters()
104104
```
105105

106106
With both the ASP.NET and ASP.NET Core app updated, extension methods can now be used to set up [remote app authentication](xref:migration/fx-to-core/areas/authentication#remote-authenticationn) or [remote session](xref:migration/fx-to-core/areas/session#remote-app-session-state), as needed.
107+
108+
## Proxying
109+
110+
To enable proxying from the ASP.NET Core application to the ASP.NET Framework application, you can set up a fallback route that forwards unmatched requests to the legacy application. This allows for a gradual migration where the ASP.NET Core app handles migrated functionality while falling back to the original app for unmigrated features.
111+
112+
1. Install the YARP (Yet Another Reverse Proxy) NuGet package following the [latest guidance](~/fundamentals/servers/yarp/getting-started).
113+
114+
1. Add the required using statements to your `Program.cs`:
115+
116+
```csharp
117+
using Microsoft.Extensions.Options;
118+
using Microsoft.AspNetCore.SystemWebAdapters;
119+
```
120+
121+
1. Register the reverse proxy services in your `Program.cs`:
122+
123+
```csharp
124+
builder.Services.AddReverseProxy();
125+
```
126+
127+
1. After building the app and configuring other middleware, add the fallback route mapping:
128+
129+
```csharp
130+
var app = builder.Build();
131+
132+
// Configure your other middleware here (authentication, routing, etc.)
133+
134+
// Map the fallback route
135+
app.MapForwarder("/{**catch-all}", app.ServiceProvider.GetRequiredService<IOptions<RemoteAppClientOptions>>().Value.RemoteAppUrl.OriginalString)
136+
137+
// Ensures this route has the lowest priority (runs last)
138+
.WithOrder(int.MaxValue)
139+
140+
// Skips remaining middleware when this route matches
141+
.ShortCircuit();
142+
143+
app.Run();
144+
```
145+
146+
With this configuration:
147+
148+
1. **Local routes take precedence**: If the ASP.NET Core application has a matching route, it will handle the request locally
149+
2. **Fallback to legacy app**: Unmatched requests are automatically forwarded to the ASP.NET Framework application
150+
3. **Middleware optimization**: The `.ShortCircuit()` method prevents unnecessary middleware execution when forwarding requests
151+
152+
This setup enables a seamless user experience during incremental migration, where users can access both migrated and legacy functionality through a single endpoint.

aspnetcore/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,8 @@ items:
21352135
uid: migration/fx-to-core/areas/webapi
21362136
- name: ClaimsPrincipal.Current
21372137
uid: migration/fx-to-core/areas/claimsprincipal-current
2138+
- name: Miscellaneous
2139+
uid: migration/fx-to-core/areas/misc
21382140
- name: Example Migration
21392141
items:
21402142
- name: Overview

0 commit comments

Comments
 (0)