Custom URL Routing in Blazor

Viewed 26

Not having done much with MVC (lots and lots of ASP.NET Applications though) and Blazor, I'm fighting to get my head around how to accomplish what I want in Blazor.

In ASP.NET I would use the NuGet package for FriendlyUrls to accomplish this task.

I want to be able to define a list of URLs or generate them on the fly and have them route to a page I already created.

For example, I might have www.sitename.com/MyArticleName and I want it route to www.sitename.com/articles/1/ behind the scene. So the URL would look like /MyArticleName but in reality it's rendering the /articles page with a fixed ID.

My table in the DB is basically (a bit more to it though) is URL, Rewrite URL.

I can define the routes up front in some cases but when it comes to things like the articles , I would rather not define all the URLs up front as the user can add/rename/delete articles at any time.

Hopefully that makes sense. I know I can do a page like @page "/articles/{articlename}", but I don't want the user to see the /articles part of the URL.

0 Answers
Related