Add ServiceStack to your project

ServiceStack is an easy drop-in that simplifies creating Web Services in any ASP.NET App, but also in Self Hosting Console Apps, Windows Services and Desktop Apps - for both .NET & .NET Framework. The easiest way to get started is to create a new project from a ServiceStack VS.NET Template.

These packages include the Free Usage Quotas listed below. The list of supported packages are also listed on nuget.org/profiles/ServiceStack. Dedicated support for these packages is available for Windows, Linux and OSX on .NET Core or Windows only for .NET Framework.

Just ServiceStack

Minimal install of ServiceStack, create an empty ASP.NET project and:

Dependencies

  • ServiceStack.Common
  • ServiceStack.Client

The docs on Creating your first web service using ServiceStack's VS.NET Templates are an easy way to Get Started with ServiceStack.

Once comfortable with creating a ServiceStack web service, we also recommend exploring ServiceStack by walking through the EmailContacts solution for a guidance on the recommended layout and configuration of a typical medium-sized ServiceStack project.

ServiceStack with OrmLite, Redis and adapters

Using Redis or OrmLite, create an empty ASP.NET project and:

Dependencies

  • ServiceStack
  • ServiceStack.Redis
  • ServiceStack.OrmLite

Server project includes Auto Query, Autogen, Redis MQ, Redis Server Events, Redis Request Logger OrmLite Cache Provider and OrmLite Auth Repository

Add ServiceStack with advanced HTML Support

If you plan on using ServiceStack to also create HTML websites then start with one of these 2 packages instead:

ServiceStack with .NET 5 or ASP.NET MVC

You want to use ServiceStack together with an ASP.NET Core or ASP.NET MVC Website, Create an Empty Project and:

Dependencies

  • ServiceStack

After it's added to your MVC Project you'll need to follow the guidelines in MVC Integration and ensure ServiceStack is properly integrated.

ServiceStack with Razor Support

You want to use ServiceStack's built-in support for Razor, Create an Empty ASP.NET Project and:

Dependencies

  • ServiceStack

We recommend reading the Razor Rockstars website to explore ServiceStack's Razor features.

Using Redis or OrmLite?

If you've started with ServiceStack.Server you already have OrmLite and Redis, if not you can add them individually:

Redis Client

Redis is a popular and indispensable tool in creating high-performance systems. It's often used as a cache, but as it supports comp-sci collections, Pub/Sub, Transactions and server-side LUA scripting, it's finding more use-cases every day.

Dependencies

  • ServiceStack.Common

Running Redis on Windows

See the Download and installation instructions for the 2 most popular ways of running redis on windows.

OrmLite

OrmLite is a fast, simple, convention-based, config-free lightweight ORM that uses code-first POCO classes and Annotation attributes to infer and generate RDBMS table schemas. It's simply provides extension methods over ADO.NET's IDbConnection so is highly-flexible and can even be easily used seamlessly with other Micro ORM's like that uses extension methods like Dapper.

OrmLite has packages for all major RDBMS's, and you just need to install the package for the one you're using, which typically for .NET will be SQL Server:

Dependencies

  • ServiceStack.Common

Otherwise if using an alternative database, install the one you need:

Just ServiceStack.Text?

JSON, JSV, CSV Serializers

ServiceStack.Text is a high-performance dependency-free library that contains all of ServiceStack's text processing, automapping utilities.
It includes 100's of enhancements to .NET's built-in String, Stream, Bytes, List, Dictionary, Reflection, Task and WebRequest types.

You will only need to install this when using on its own as ServiceStack.Text is already a dependency on all other ServiceStack NuGet packages.

Android, iOS, Windows Store, WPF and Silverlight clients should install the ServiceStack.Client package:

Message Queue Servers

ServiceStack's message-based design enables it to host Services on a variety of different transports including a number of different MQ Servers via the Messaging API all MQ Servers implement making it trivial to swap between different MQ Brokers.

Rabbit MQ

Rabbit MQ is a popular industrial strength open source implementation of the AMQP messaging protocol for communicating with MQ middleware on all major OS's.

Running RabbitMQ on Windows

See the installation and getting started guide for a walkthrough on setting up Rabbit MQ on windows and accessing it from C#.

ServiceStack Rabbit MQ

See ServiceStack's Rabbit MQ docs for an explanation on how Rabbit MQ works with ServiceStack and details on its message workflow.

Azure Service Bus

If you're hosted on Azure you can utilize Azure Service Bus's highly-reliable and managed cloud messaging service or Windows Service Bus if running Service Bus on Windows Server.

Redis MQ

If Redis is already apart of your infrastructure, Redis MQ is an attractive choice to use as an MQ Broker without needing to add any additional infrastructure dependencies.

 

Amazon SQS

If you're hosted on AWS you can take advantage Amazon's reliable, scalable, fully managed message queuing service. SQS makes it simple and cost-effective to decouple the components of a cloud application. You can use SQS to transmit any volume of data, at any level of throughput, without losing messages or requiring other services to be always available.

In Memory MQ

ServiceStack.Server also includes an In Memory MQ option useful for testing and for when other MQ Broker options are not available. Although not being able to accept network requests limits its usefulness.

Amazon Web Services

You can participate in AWS's vibrant ecosystem with ServiceStack's first-class support and deep integration with AWS that seamlessly integrates with popular back-end AWS technologies allowing hosting of ServiceStack solutions entirely on the managed AWS platform

ServiceStack.Aws

All of ServiceStack's support for AWS is encapsulated within the single ServiceStack.Aws NuGet package:

Dependencies

  • ServiceStack
  • AWSSDK.Core
  • AWSSDK.DynamoDBv2
  • AWSSDK.S3
  • AWSSDK.SQS
The ServiceStack.Aws NuGet package includes implementations for the following ServiceStack providers:

Microsoft Azure

ServiceStack.Azure

All of ServiceStack's support for Azure is encapsulated within the single ServiceStack.Azure NuGet package:

ServiceStack.Azure includes implementation of the following ServiceStack providers:

Caching and Logging Providers

Caching

In Memory Caching is available in ServiceStack and ServiceStack.Redis includes the Redis cache client, whilst an OrmLiteCacheClient is available in ServiceStack.Server for utilizing an existing RDBMS as a distributed cache.

Other External caching providers are also available:

AWS Dynamo DB:

Dependencies

  • ServiceStack
  • AWSSDK.Core
  • AWSSDK.DynamoDBv2
  • AWSSDK.S3
  • AWSSDK.SQS

Memcached:

Dependencies

  • ServiceStack.Common
  • EnyimMemcached

Azure:

Dependencies

  • ServiceStack.Common
  • WindowsAzure.Caching

Logging

ServiceStack also provides an implementation and dependency-free logging API with adapters for all of .NET's popular logging providers. It allows your business logic to bind to an easily-mockable and testable dependency-free interface whilst providing the flexibility to switch logging providers at runtime.

Console, Debug and Empty logging providers are already in ServiceStack, whilst you can use NuGet to get the adapter for your preferred logging framework:

Additional Formats

Protocol Buffers

Protocol Buffers is a high-performance, compact binary wire format invented by Google who use it internally so they can communicate with their internal network services at very high speed.

You can add it to ServiceStack with:

Message Pack

Message Pack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON but it's faster and smaller and unlike ProtoBuf supports attribute-less POCOs.

You can add it to ServiceStack with:

Client Libraries

As ServiceStack is just a pure HTTP web service it can be accessed with any HTTP-capable client. However in order to provide the least friction and most productivity end-to-end, we also maintain generic C# clients available at:

Or use the HttpClient-based JsonHttpClient instead with:

Also includes Android, iOS, Windows Store, WPF and Silverlight clients, see Mobile documentation for more info.

See the Hello Repository for a portable solution showing how to re-use DTO's and client libraries between Android, iOS, Windows Store, WPF and Silverlight platforms.

 

Service Clients are unrestricted

Explicitly included in the free quotas is an exception enabling free, unrestricted use of ServiceStack Service Clients for calling any ServiceStack service.

 

.Core Packages

Use .Core packages if running ServiceStack ASP.NET Core on .NET Framework.

External Libraries

Stripe

Contains a typed .NET client gateway for accessing Stripe's REST API to process merchant payments and recurring subscriptions online.

See the Stripe GitHub repository for documentation and example source code.

 

ServiceStack.CefGlue

Contains CefGlue bindings for .NET Standard 2.0 with support for running Windows 64 Desktop Applications.

See the project and vuedesktop.com website for documentation and examples.

 

License Registration

The ServiceStack license key allows un-restricted access to ServiceStack packages and is available in your My Account Section after purchasing a commercial license.

There are multiple ways of registering your license key which all need to be added to your top-level host project:

a) Add it to the projects appsettings.json or Web.Config

Easiest way to register your license key is to add the servicestack license appSetting. For ASP.NET Core Apps add it to appsettings.json:

{
    "servicestack": {
        "license": "{licenseKeyText}"
    }
}

Non ServiceStack .NET Core AppHost Apps (i.e. just using Redis or OrmLite) will also need to explicitly register the license key from IConfiguration:

Licensing.RegisterLicense(Configuration.GetValue<string>("servicestack:license"));

For .NET Framework Applications add it to the Web.config or App.config's <appSettings/> config section:

<appSettings>
    <add key="servicestack:license" value="{licenseKeyText}" />
</appSettings>

b) Add it in code before your Application Starts Up

By calling Licensing.RegisterLicense() before your application starts up, E.g. For ASP.NET, place it in the Global.asax Application_Start event:

protected void Application_Start(object sender, EventArgs e)
{
    Licensing.RegisterLicense(licenseKeyText);
    new AppHost().Init();
}

Otherwise for a self-hosting Console Application, place it before initializing the AppHost, as shown above.

c) Add the System Environment Variable

To simplify license key registration when developing multiple ServiceStack solutions you can register the License Key once in the SERVICESTACK_LICENSE Environment Variable on each pc using ServiceStack libraries:

Variable Value
SERVICESTACK_LICENSE {licenseKeyText}

You'll need to restart IIS or VS.NET for them to pickup any new Environment Variables.

d) Copy license key text into an external text file

Similar to above, we can register the license from an external plain-text file containing the license key text, e.g:

protected void Application_Start(object sender, EventArgs e)
{
    Licensing.RegisterLicenseFromFileIfExists("~/license.txt".MapHostAbsolutePath());
    new AppHost().Init();
}

For Self-Hosting set BuildAction to Copy if Newer and use "~/license.txt".MapAbsolutePath() method.

The license key is white-space insensitive so can be broken up over multiple lines.

Free Quotas

Whilst ServiceStack v4+ is a commercially-supported product, we allow free usage of our Commercial Products in small projects and for evaluation purposes.

The NuGet packages above include the quota's for our Commercial Products below which can be unlocked with a license key:

  • 10 Operations in ServiceStack (i.e. Request DTOs)
  • 10 Database Tables in OrmLite
  • 10 DynamoDB Tables in PocoDynamo
  • 20 Different Types in Redis Client Typed APIs
  • 6000 requests per hour with the Redis Client

You can evaluate all of ServiceStack without these restrictions with our 30 Day Free Trial.

The rest of ServiceStack outside of these free-usage quotas can be used without a developers license subject to ServiceStack's License Agreement. A commercial license is required to access commercial support options.