This very website, A Dev Solved It, is an ASP.NET Razor Pages application.
For a given Post page, different URLs work, as long as the first part, with the post id, is the same.
For SEO purposes, I wanted though to set a canonical URL for each post.
I looked around a bit, but I didn't find a simple answer of how to generate a link rel canonical for Razor Pages, most existing results are for ASP.NET MVC.