Servicestack reverse routing exception

72 views Asked by At

I'm trying to get the absolute url out of a ServicesSatck service but I'm receiving the following exception:

None of the given rest routes matches 'SingleUser' request: /user/UserName/{UserName}: Allowed HTTP methods 'Get' does not support the specified 'GET' method.

SingleUser class has the following routes declared as metadata :

   [Route("/user", "Get")]
   [Route("/user/{Id}", "Get")]
   [Route("/user/UserName/{UserName}", "Get")]

The exception apepars when I try to call

   var url = new SingleUser { UserName = userSession.UserName}.ToAbsoluteUri();

Am I doing something wrong?

1

There are 1 answers

0
gjspaho On BEST ANSWER

Eventually the problem was with the capitalization of the HTTP method on the route declaration. It worked after I set the route as follows

[Route("/user/UserName/{UserName}", "GET")]

The service has been working, even when it was declared as "Get" but the "ToAbsoluteUri()" brought up the problem.