Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

GettingStarted

gregmac edited this page Feb 13, 2012 · 2 revisions

Getting Started With NServiceMVC

Getting up and running with NServiceMVC is very simple, and will be familiar to anyone who knows MVC already.

1. Create a new MVC3 project (or use an existing one)

This can be a new Empty MVC3 project, created from a template, or even an existing project.

2. Add NServiceMVC

The easiest way is via Nuget. Install using the Package Manager GUI, or from the Package Manager console type:

Install-Package NServiceMVC

3. Create a Service

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.

4. Run the project

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.

Further Reading

Read more about DefiningServices, ErrorHandling and ConfigurationOptions.

Clone this wiki locally