Maybe there is a different extension method, that I’m not seeing.
I have a DTO object for a website razor page, actually many, one for each razor page.
I want only the [Route("/my-route/{param1}")] attribute representation of the url. Not the ServiceStack returned route /json/reply/MyDto. Is there a way to only return the Route attribute version?
I’m running into an issue where some Dtos return the route attribute others return the /json/reply.... I want to be able to always get the route attribute version.
Basically I’m doing:
// page is the dto
page.ToGetUrl()
The reason for this is that a razor web page is not going to use /json/reply... and these are going into link tags <a href="@page.ToGetUrl()">.
At the moment the routes are changing frequently and it doesn’t make sense to hard code routes to pages.
It should choose the most appropriate Route based on the properties of the Request DTO, so if there’s a custom [Route] that satisfies the populated Request DTO it should use it, otherwise if it can’t find a match it falls back to use the pre-defined routes.
So make sure the {param} property is populated on the Reqeust DTO you’re calling .ToGetUrl() on.
Weird. Looks like Resharper -> refactor -> rename created the renamed ServiceModel class & file but didn’t remove the old. Or some human mistake happened
For whatever reason that ServiceModel dto’s were the ones producing those url /json/reply... urls. I’ve chosen the correct dto’s and it seems to be working now.
So that I’m clear .ToGetUrl() should always choose the [Route] first?
The reason for my clarification, is that these urls will be in html <a href... and <meta name="canonical"... tags, and wouldn’t be good if Google indexed the /json/reply....