evilmandarine
evilmandarine

Reputation: 4553

How to use predefined routes in ServiceStack with URI instead of query string?

Is it possible (if yes, how) in ServiceStack to use predefined routes with parameters in the URI? I can do one or the other but combining both does not seem to work:

[Route("/hello/{Name}")]

// ok
1. /hello/myname
2. /json/reply/hello
3. /json/reply/hello?Name=myname

// not ok
4. /json/reply/hello/myname
"The operation 'myname' does not exist for this service"

Tried these but none worked:

[Route("/*/hello/{Name}")]
[Route("/{*}/hello/{Name}")]

In particular, why does 3 work, but not 4? Thanks!

Upvotes: 3

Views: 143

Answers (1)

mythz
mythz

Reputation: 143319

No, ServiceStack's pre-defined routes are not customizable and follow the explicit format:

/{format}/[reply|oneway]/{servicename}

i.e. you can define your own Custom routes, but you can't change the pre-defined routes which maintains its pre-defined behavior.

To send parameters on the URL you need to use the queryString, e.g:

 /json/reply/Hello?name=myname

Otherwise you can send parameters using other methods that ServiceStack supports, e.g. serialized Request Body, FormData, HTTP Headers, etc.

Upvotes: 1

Related Questions