-
Notifications
You must be signed in to change notification settings - Fork 2
GettingStarted
Getting up and running with NServiceMVC is very simple, and will be familiar to anyone who knows MVC already.
This can be a new Empty MVC3 project, created from a template, or even an existing project.
The easiest way is via Nuget. Install using the Package Manager GUI, or from the Package Manager console type:
Install-Package NServiceMVC
A service is simply a controller that inherits from NServiceMVC.ServiceController.
The simplest example is:
public class HelloController : ServiceController
{
[GET("hello")]
public string Index()
{
return "Hello there";
}
}
See DefiningServices for more information.
By default, metadata is served at ~/metadata, and the page there will list all your service URLs.
If you included the above sample controller, you can view the service response by going to ~/hello in your browser. This will display the XHTML output. If you go to ~/hello?format=json (or xml, etc) you can view the alternative representations. Using a string isn't very interesting, but try defining a new model class and returning that.
Read more about DefiningServices, ErrorHandling and ConfigurationOptions.