I continue to experiment with learning ASP.NET Core Razor Pages with RemObjects Mercury. The other day I was having a problem using Visual Studio 2022 – I would add a new Razor Page to the project, and then add an Anchor element with an asp-page reference to the in my _Layout.cshtml file, but when I tried to test the project, the resulting hyperlink didn’t work. For example, if I added a new “About.cshtml” page, and then added this link in my _Layout.cshtml file:
<a class="nav-link text-dark" asp-area="" asp-page="/About">About</a>
I was expecting the resulting hyperlink to href to be “/About”. Instead, it was “About”.
It turns out that in your project file (in my case, a “*.elements” file), it is important that the reference to the page is created as a <Razor> node, and not as a generic <Content> node. In my case, a bug mean it was added as a <Content> node, which is why it wasn’t working.
Unloading the project, and editing the reference manually solved this issue for me.