Reputation: 31
I'd greatly appreciate if someone could kindly explain [Route] attribute / routes.Add() method, its parts. I'm used to MVC framework / WebAPI and know that those pertain to Controllers and Actions. For instance the classes, DTO objects have them as opposed to methods. Thanks a bunch in advance.
Update 7/17/2013 http://pluralsight.com/training/Courses/TableOfContents/service-stack
Excellent course that answers everything
Upvotes: 1
Views: 383
Reputation: 1279
The route attributes you are referring to routes specific dtos to services based on the path in the route. so something like base.Routes.Add("/files", "GET,POST") would allow GET and POST requests to the /files path. So if my api lives in /api I can hit
http://localhost/api/files
with a GET or a POST and it should be routed to the correct service(s). You can think of this like what mvc does and keep in mind that mvc WILL mess with teh routes of service stack if the path is not ignored in mvc. In your route config of mvc make sure to put something like this:
routes.IgnoreRoute "api/{*pathInfo}"
assuming you installed service stack to run on the path /api (this can be found in your web.config). Also, if you are using mvc4 i would recommend taking out the webapi stuff so you dont get any conflicts with that either.
Upvotes: 1