-
Notifications
You must be signed in to change notification settings - Fork 2
Definingservices
All services extend NServiceMVC.ServiceController
. These work exactly like regular services, but instead of returning an ActionResult, they return a typed model object.
Return values can be any value that is serializable. The only thing to note here is that the built-in Dictionary object is not serializable as XML, so if you're using that please ensure you use a wrapper or one that is compatible with XML serialization.
Typically you should use a data transfer object (DTO) for return values. This is simply a POCO (plain old CLR object) that contains no business logic, is it just used for transferring data (hence the name DTO). Note that simple types like integer, string, etc can be considered DTOs, and they are quite valid return types.
You can also return arrays/enumerables. NServiceMVC will interpret and show anything that returns an IEnumerable as if it returns an array of the same type (in other words, a method that returns string[]
looks the same to the remote client as a method that returns IList<string>
).
Parameters are passed using all the same conventions that work with MVC 3.
See ErrorHandling