I'm fairly certain this is a case of Visual Studio Development Server not acting like 'real' IIS. I just tested this myself:
- VS 2012, created new empty ASP.NET project
- Used NuGet to import Starter Template for ServiceStack 3.9.59.0
- created a service and DTOs based on your case
- press F5 - run on localhost
- /usergroup/joe.schmoe/mygroup/ - this works with IISExpress - route is found and returns output correctly
- switch to use "Visual Studio Development Server"
- F5, run /usergroup/joe.schmoe/mygroup/ again
- Route fails - "Handler for Request not found:"
The problem will go away if you edit your project Web properties and check "Use IIS Express" instead of "Visual Studio Development Server".
The cases to use IIS Express are explained here
I also found another SO answer which is a similar case.
Luckily, the answer there contains a bad link reference, but quotes the actual text.
This is the code i used:
public class UserGroupService : Service
{
public object Any(UserGroupRequest request)
{
return new UserGroup { User = "Got: " + request.User, Group = "Got: " + request.Group, };
}
}
[Route("/usergroup/{User}/{Group}", "GET")]
public class UserGroupRequest
{
public string User { get; set; }
public string Group { get; set; }
}
public class UserGroup
{
public string User { get; set; }
public string Group { get; set; }
}
Update: i found a good link to the reference ee941656
If you create a file system Web site in Visual Studio 2010 and the Web site is in a folder that contains a dot (.) in the folder name, URL routing will not work reliably. An HTTP 404 error is returned from some virtual paths. This occurs because Visual Studio 2010 launches the Visual Studio Development Server (Cassini) using an incorrect path for the root virtual directory.
There are 3 workarounds, and only the "use IIS instead of Cassini" workaround seems to work.