Reputation: 11
I am working on a migration from ASP.NET to ASP.NET Core and in the new setup, I am leveraging the Blazor FluentUI components. I have YARP setup to proxy unmapped requests to the classic ASP.NET server.
YARP is working as expected when I access a legacy route (e.g. /Login.aspx, etc.). But the trouble is, any Blazor FluentUI component I render yields a 404 NOT Found because the component bundle request is being proxied to the classic ASP.NET server. Here is the output from YARP:
Yarp.ReverseProxy.Forwarder.HttpForwarder: Information: Proxying to http://legacy-aspnet-server/_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js HTTP/2 RequestVersionOrLower
Anyone have this setup and can point me in the right direction for how to get the correct setup?
I have scoured the MS Docs and Github repos, etc. to find what I may be missing but keep coming up empty.
Upvotes: 1
Views: 251
Reputation: 156
Looking at what Microsoft does for _framework
directories here:
https://github.com/dotnet/aspnetcore/blob/5d0e3b0513a1fd71aa4a63029b91d57504b59345/src/Components/WebAssembly/Server/src/WebAssemblyRazorComponentsBuilderExtensions.cs#L53
It looks like setting the endpoint to null off the context is supposed to allow the static files middleware to handle the request (based on their comment in the above file).
You might consider similarly intercepting the request with _content
in the path and setting the endpoint to null. Something like the following:
var app = builder.Build();
app.UseAntiforgery();
app.Use(async (context, next) =>
{
if (context.Request.Path.Value.Contains("/_content/"))
{
context.SetEndpoint(null);
}
await next.Invoke();
});
Upvotes: 0