-
Notifications
You must be signed in to change notification settings - Fork 66
Add IEndpointRouteBuilder.MapBlazorPages extensions to explicitly map blazor pages #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the interesting part - the rest is to add a sample
… blazor pages Currently, if you try to use Yarp with Blazor pages, it will not work as expected. Both of these currently expect to be the fallback. This adds in an extension method that will allow you to explicitly register blazor pages so they don't require a fallback anymore.
e2bcd69
to
ddf80ab
Compare
Blocked on API review here: dotnet/aspnetcore#46170 |
@twsouthwick Just did some quick testing and unfortunately this new extension method Since the reason for this additional extension method is to help facilitate migration from older .NET Framework web projects (MVC/Web Forms) by using the strangler-fig pattern with YARP as a reverse-proxy (aka one-page-at-time sort of upgrade), that means for many of us we will want to make sure that our existing navigation links remain routable, while also taking advantage of the latest paradigm. For example, using web form pages will have the ASPX extension on every route by default. If I want to finally convert that page to Blazor, then I'm going to want to add multiple routes to my razor file so that the ASPX route still routes to the new stuff, but my new "default" route excludes the ASPX extension if possible. Here's an example of what that razor page would look like, although I'm sure there is probably a more elegant way to handle this.
Hope this makes sense. |
@gerneio thanks for the feedback. We're going to publish this as a doc but it will be available in ASP.NET Core 8 out of the box. I'm a little confused by the rewriting you're describing - is this a feature request or feedback on how your using it? We aren't really opinionated on what the final routes end up being, but I would imagine that main constraint would be that you want existing links to continue working. |
@twsouthwick I was just trying to show why someone would want multiple routes on their razor pages when migrating (for example) their web forms projects using the one-page-at-a-time approach (aka strangler-fig). And yes, the idea is to have existing links continue to work while the project is in limbo. TLDR, this new extension method should support pages with multiple routes, rather than throwing an exception. Btw, on those docs y'all are fixing to create, a mention of how to tackle the re-routing (i.e "/page.aspx" to "/page" IF the route exist in the new project) would be greatly welcomed. I managed to get something workable for my solution, but I have a feeling there are better approaches. Thanks! |
cool - thanks for trying it out @gerneio . I'm going to close this as we're going to put it in docs instead. |
@twsouthwick sounds good to me. Btw, what can I subscribe to so that I am notified when that doc has been completed? |
Currently, if you try to use Yarp with Blazor pages, it will not work as expected. Both of these currently expect to be the fallback. This adds in an extension method that will allow you to explicitly register blazor pages so they don't require a fallback anymore.
Fixes #53