routing all .html to proper razor pages in Server side Blazor

Robdob 1 Reputation point
2021-05-04T19:16:50.107+00:00

Hi,

I have an older website where I'm doing a lot of urlrewrite stuff to my old .aspx files. I'm now trying to covert this site to blazor and I would like to be able to access a lot of m blazor site using direct .html filenames within the urls.

so I have a .razor page and within it I have:

@page "/information-on-mystuff.html" in my razor pages

and then within the startup.cs file I have something like this:

app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");

                // I added this next line in to make /information-on-mystuff.html properly display on browser refresh
                endpoints.MapFallbackToPage("/information-on-mystuff.html", "/_Host"); 
            });

doing this works correctly but is it possible to have a wild card something like:

 endpoints.MapFallbackToPage("/*.html", "/_Host");

I have many routes that I will need to convert from my old asp.net site which is making use of the urlrewritre module extensively and I want like to know what the best way to do this is. I would also like to keep access to all of .html pages because my older site is already doing well in SEO and I don't want all these pages to disappear..

Any help would be great!

thanks in advance..

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,324 questions
0 comments No comments
{count} votes