Reuse old aspx routes in Blazor

We are writing a new version of an old page that other pages are dependent on. As such it’s important to keep old routing.

One of the routes is as follows:

I would like for this to work, but point to a blazor component.
I have tried adding it as a @page supplement to the ones I already have, but the application wont run with it.

@page "/page/{id}/{property:int?}"
@page "/page/{id}"
@page "/area/page.aspx?id={id}"

I have also tried just

@page "/area/page.aspx

but this seems not to work either. Blazor isn’t even starting when I do this. I also tested

@page "/area/page.tst

to no avail. I believe that it’s the . and ? that is the culprits.

A solution might be to redirect from the old URL to the component, with something that the @page directive can handle, but I can’t figure out where in the middleware this would be done.

Question is basically: Which ways one can reuse old URL’s with Blazor?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I found that in Startup.cs there’s a method:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

That has this in it:

app.UseEndpoints(endpoints =>

Here I could just add the following line:

endpoints.MapGet("/area/page.aspx", async x => { x.Response.Redirect("~/page/"); });

And it would redirect. Nifty 🙂

Resulting code would then be:

app.UseEndpoints(endpoints =>
    endpoints.MapGet("/area/page.aspx", async x => { x.Response.Redirect("~/page/"); });

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x