I've done quite some ASP.NET API programming over the years, but am very new to .NET Core and RazorPages. I cannot seem to get routing working properly.
For example, I have an Index page. The OnGet works fine, as expected, it returns the Razor defined page. Now I add another method, let's call it Test to the Index page codebehind, like so:
[Route("Test")]
public void Test()
{
Console.WriteLine("Test");
}
Now for the life of me, I cannot access this route, neither by localhost/Index/Test or localhost/Test or any other convoluted route I can think of. Is this by design? Both localhost and localhost/index return the default get method.
This is causing me quite a bit of trouble where I am trying to display a product's details using the owner and product Id in a pretty URL, like so:
products/{ownerid}/{productid}
As mentioned above, I cannot map to this custom pretty URL. If I understand correctly, the functions mapping to the {ownerid}/{productid} route should be in the index page codebehind in order to be found, or am I mistaken?
Thank you for your help.