servicestack Getting started with servicestack

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


This section provides an overview of what servicestack is, and why a developer might want to use it.

It should also mention any large subjects within servicestack, and link out to the related topics. Since the Documentation for servicestack is new, you may need to create initial versions of those related topics.

Installation or Setup

You can install ServiceStack in 3 ways:

  • Complete Visual studio templates (Self hosted)
  • Start from scratch run ServiceStack Self hosted (Console App)
  • Run ServiceStack inside MVC.

Complete visual studio templates

You can find info about these here:

  1. Download the servicestack Visual studio plugin:
  2. Start a new project in visual studio and choose one of the templates.

Start from scratch (Selfhosted)

For complete guide go here:

To setup:

  1. Make a Console application
  2. install ServiceStack through nuget: Install-Package ServiceStack
  3. Setup your base code. ServiceStack uses an AppHost to thigh everything together:
 //This your main entry point of the application
 public class AppHost : AppSelfHostBase {
    public AppHost() 
      : base("HttpListener Self-Host", typeof(HelloService).Assembly) {}

    public override void Configure(Funq.Container container) { }

//Run it!
static void Main(string[] args)
    var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0];
    var appHost = new AppHost()

    Console.WriteLine("AppHost Created at {0}, listening on {1}", 
        DateTime.Now, listeningOn);


Now you can start developing your api Services.

Mvc integration

For complete Mvc integration guide:

First download your nuget packages: Install-Package ServiceStack.Mvc

Setup your ServiceStack Apphost

public class AppHost : AppHostBase
    public AppHost() : base("MVC 4", typeof(MyServices).Assembly) {}

    public override void Configure(Container container)
        SetConfig(new HostConfig { 
            HandlerFactoryPath = "api" 

            new FunqControllerFactory(container));

//Bootstrap your appHost through MVC Global.asax:
public class Global : System.Web.HttpApplication
    protected void Application_Start(object sender, EventArgs e)
        new AppHost().Init();

Now to run ServiceStack services, we can add web.Config to make ServicStack run under a certain path, eg: /api/*

<location path="api">
      <add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" 

    <modules runAllManagedModulesForAllRequests="true"/>
    <validation validateIntegratedModeConfiguration="false" />
      <add path="*" name="ServiceStack.Factory" 
           type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" 
           resourceType="Unspecified" allowPathInfo="true" />

Got any servicestack Question?