Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
What's in ServiceStack?
Click the box to peek inside
ServiceStack is a config-free, code-first web and services framework embraced around Martin Fowler's remote-service best-practices in idiomatic C# - with implicit support for returning popular .NET's response types, idiomatic handling of C# Exceptions and full-control over HTTP Responses.
It's message-based design provides the most advantages for remote services encapsulating them in their most re-usable form allowing the same service to be called in REST, SOAP, MQ services enabling .NET's most succinct, end-to-end typed API without the use of code-gen, additional machinery or post build steps.
- WCF, WCF/REST, .asmx, Web-API, MVC, WebForms, WebPages, CSF, WSE, WCF DataServices, RIA Services, System.Messaging
Contained in the ServiceStack.Authentication.OpenId NuGet package is ServiceStack's support of OpenId 2.0 Authentication. This allows ServiceStack-enabled ASP.NET / MVC sites and web services to authenticate and accept registration from any OpenId 2.0 Authentication provider.
Like most .NET OpenId libraries the de-facto and excellent DotNetOpenAuth library is used to enable our OpenId support.
Included OpenId providers:
- My OpenId as well as support for any other Custom Open Id provider
As caching is an essential technology in the development of high-performance web services, Service Stack has a number of different caching options available that each share the same common client interface for the following cache providers:
- Redis, Memcached, InMemory, Azure, DynamoDb
Any response can be cached with the in-built Caching Pattern available in the ToOptimizedResultUsingCache extension method. This caches the most optimal result for all formats (inc. user-defined), i.e. if your browser supports gzip/deflate it will cache the compressed output.
ServiceStack includes the ability to limit the visibility and accessibility of services using built-in declarative Restrict attributes. Restrictions can be applied on the different attributes of a Service request including it's network proximity, endpoint type, format, encryption, call style, http method, etc.
Visibility controls whether its existence is publicized on externally viewed metadata pages and services, whilst accessibility restrictions controls which usage scenarios the service can be called.
It supports multiple fine-grained restriction scenarios that can easily enforce popular configurations like hiding admin services or only allowing HTTP plain-text traffic from Internal Networks and only allow external access via secure HTTPS.
Built into ServiceStack is an optional Authentication feature that can be used to add Authentication to existing services to Authenticate and Assign/UnAssign Roles to existing as well as registering new users.
Highly substitutable and customizable and easy to plug-in custom Auth logic, and change back-end caching and session providers used to persist UserAuth data. By default transparently merges Auth and user data from:
- Credentials, Basic Auth, Digest Auth, Custom Auth, Twitter OAuth, Facebook OAuth and OpenId
It integrates seamlessly with the rest of ServiceStack and allows UserAuth info to be stored in multiple repositories:
- OrmLite, Redis, InMemory, Mongo DB, Raven DB, NHibernate. Session: InMemory, Redis, Memcached, Azure, AWS DynamoDb
ServiceStack's Sessions is an efficient, clean API supporting both typed and dynamic access that works on top of any of ServiceStack's existing caching providers.
Unlike ASP.NET's built-in sessions, it doesn't have any degrading performance locking issues, instead access to sessions is optimistic and the typed Session API enables atomic access session information. The Authentication feature transparently leverages the Session support to provide instant access to an authenticated users session information.
Since the Session support is built-on clean, legacy-free and code-first APIs, they are easily accessed from other ASP.NET frameworks where the same ServiceStack session can be shared between WebForms or MVC.
Thanks to its message-based design, ServiceStack Services are already well suited for processing by MQ Brokers. As MQ services promote low-coupling and provide the most durable and reliable link between two endpoints, it is more suitable for many offline, background and parallelizable tasks that have historically only been done with web services.
ServiceStack greatly improves the dev experience as it lets you re-use existing Services saving all the dev effort required to implement, whilst letting you trivially debug them since they're available as a normal REST service.
By default ServiceStack ships with a distributed Redis MQ and an InMemory and RCON MQ Hosts. In future we intend to provide MQ Service adapters for RabbitMQ, Amazon SQS, Azure ServiceBus and ZeroMQ brokers.
.NET's leading C# client for the Redis NoSQL datastore. Redis is one of the fastest and most feature-rich key-value stores to come from the NoSQL movement. It is similar to memcached but the dataset is not volatile, and values can either be stored in comp-sci data structures including strings lists, sets, sorted sets or hashes.
It includes in-built support for Pub/Sub, Transactions, Pipelining and supports Server-side Lua scripting. Due to its simplicity and performance it's widely used by many of the highly scalable, top Internet companies. more...
In order to accessing physical files in view engines from multiple sources, ServiceStack includes its own pluggable virtual file system API that lets it support multiple filesystem backends.
The virtual file system (VFS) is what allows ServiceStack to support view engines in a standard ASP.NET websites (e.g. serving directories from the root directory) as well in self-hosting stand-alone HttpListener websites and Windows Services serving from the output /bin directory as well as embedded resources inside .dlls, any combination of both and in future from remote datastores.
In addition to the built-in auto-generated metadata pages, ServiceStack also includes support for Swagger a popular metadata service description and UI to describe and introspect REST services. The SwaggerFeature is available in the ServiceStack.Api.Swagger NuGet package that's easy value-add to any existing ServiceStack instance.
Swagger builds on the existing Route and DataMember metadata DTO attributes shared by ServiceStack's built-in automated metadata pages and adds Custom Api and ApiMember attributes you can use to further annotate your services for Swagger.
Even in the spirit of Bind to interfaces, not implemenations, many .NET projects still have a hard dependency to log4net.
ServiceStack.Logging is an implementation and dependency-free logging API with adapters for all of .NET's popular logging providers. Itpu allows your business logic to bind to an easily-mockable and testable dependency-free interface whilst providing the flexibility to switch to any of the available logging providers:
Profiling runs at the heart of any high-performance solution which was why the excellent Mini Profiler was ported and built right into ServiceStack. Once enabled, the auto HTML pages of each service will include the Mini Profiler info widget which when expanded provides a detailed summary view highlighting where all the time processing the request was spent.
In addition to viewing the overall time spent on different parts of ServiceStack's request pipeline, you can continue to break them down further with by adding your own custom fine-grained profiling timing blocks.
ServiceStack was designed from the ground up to promote best practice remote service and code development best-practices. With these goals we embed a port of the extremely fast and minimal Funq IOC which contains 90% of the most used features behind an intuitive API at a fraction of the code-size of most Heavy-weight IOC's which perform orders of magnitude slower. We've enhanced Funq to add support for Auto-wiring and Request lifetime scope.
Alternatively you can opt to use your preferred IOC instead which is supported via the IContainerAdapter interface. The IOC wiki includes instructions on enabling Ninject, StructureMap, Windsor and AutoFac IOC's.
HTML support works just as you would expect it to in a REST service framework - you can re-use existing services and treat HTML as just another Content-Type and make use of any of the in-built and pluggable MVC Razor, Markdown Razor and HTML Report ViewEngines.
Thanks to its tight integration, ServiceStack's HTML story is packed with features not found in alt frameworks
- Mix & Match: Include Markdown in Razor views
- No Ceremony option - Dynamic-only pages
- Change Views and Layout templates at runtime
- Support for multiple base classes and Razor .exts
- Optimizing for productivity and Single Page Apps
- MVC, WebForms, WebPages
Markdown is quickly becoming the preferred way to maintain any kind of textual content which has seen its popularity surge in recent years thanks to its adoption by StackOverflow, GitHub and as the preferred markup to store a number of blogs.
We love Markdown so much we developed a hybrid Markdown Razor format blending best features of our 2 favourite template languages: Markdown and MVC Razor resulting in a capable content-optimized template for rendering content-heavy websites like ServiceStack Docs
Markdown is a first-class View Engine in ServiceStack's HTML Story which thanks to its tight integration is able to support the ideal use-case of using Razor to structure the layout of your website whilst embedding Content maintained in Markdown as a Partial View.
As validation and error handling is an essential part of developing services, ServiceStack provides a rich array of error handling options that work intuitively out-of-the-box, emitting the appropriate HTTP Status Codes and error responses on the wire.
Optimized for developer happiness ServiceStack allows you to idiomatically throw C# exceptions directly in your services or to declaratively specify validation rules using the excellent Fluent Validation framework and trivially consume them on the client in a end-to-end typed API, intuitively and conventionally with minimal effort. The flexible Error Handling support also allows injecting custom generic error handling routines to handle errors.
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.
OrmLite API's are simply extension methods over ADO.NET's underlying System.Data interfaces and so allows unrestricted access to any DB query, whilst also exposing DRY, easy-to-use, flexible and expressive APIs for all common data access patterns including a typed expression-based LINQ-like API.
Includes transparent blob storage for any complex property type and supports most major RDBMS's: SqlServer, Sqlite, MySql, PostgreSQL, Oracle, Firebird.
- Entity Framework
Configuration is another area in .NET suffering from over-complication, over-use, tight-coupling and un-necessary friction. Only configurable parts of your app should be exposed in the Web.config, as it is a less capable, less verifiable and more brittle option than configuring deps in code.
This is another point of friction we solve with our impl-agnostic Config API which leverages the human-friendly JSV Format to in maintaining typed values, .NET collections and rich complex object graphs (hydrated into POCOs), inside a single human-friendly appSetting.
The dep-free API decouples the configuration of your dependencies from the Web.config and allows the ideal scenario of being able to specify default values in code, whilst remaining overridable with any Config source, e.g. Web.Config or Generic Dictionary, etc.
Often when developing or diagnosing software you will find the need to log and introspect .NET objects during debugging, whilst creating tests, or with runtime logging.
Rather than manually inspecting watch lists, or manually writing out print statements for individual properties, ServiceStack provides the handy Dump() extension method to return a recursively pretty printed dump of an object graph as well as Print() and PrintDump() methods to print formatted strings and objects directly to the console.
These diagnostic utils are all available as extension methods allowing for fluid chained-expressions on any object or string.
Although we encourage the remote service best practices of keeping separate DTO models, you wont need to maintain your own manual mapping yourself as you can leverage ServiceStack's built-in Auto Mapping support.
The Auto-mapping support is resilient and comprehensive and does a great job of fuzzy mapping in being able to co-erce values of one type into another, e.g. you can convert between different Enum types with the same name, between Enums and any value type and Strings, between properties and fields, POCOs and strings, vice-versa and many things in between.
Contains .NET's fastest JSON and text serializers - .NET's second most popular JSON Serializer on NuGet. Popular with perf conscience companies like StackOverflow. Includes JSON, CSV and JSV Formats. All serializers expose succinct and easy to use multi-purpose generic APIs.
Includes a comprehensive feature-set: lock-free / thread-safe, idiomatic JSON, late-bound / abstract and interface data types, dynamic JSON parsing, efficient structs, a number of hooks and extension points to override and inject custom behavior and more...
Being developed on top of raw ASP.NET Http Handlers has many benefits, one of them is that we're built on top of the ASP.NET HTTP abstractions so we're able to easily integrate with other ASP.NET frameworks like WebForms and ASP.NET MVC.
As it's built-on clean, dep-free code-first providers, all of ServiceStack's Session, Caching, Funq IOC, ORM, Redis, Config and Logging is easily re-used inside MVC.
You can re-use ServiceStack's Funq IOC and all registered dependencies in MVC, access the same ServiceStack User Session, use ServiceStack's Authenticate Filter attributes on MVC Controllers, Call ServiceStack services directly from MVC and easily convert an MVC Http Context into ServiceStack Request Context allowing you to easily proxy MVC Http Requests to ServiceStack services to handle.
Protocol Buffers is a high-performance, compact binary wire format invented by Google who use it internally for almost all of its internal RPC protocols and file formats.
ProtoBuf is a great addition to your ServiceStack services which includes .NET's 2 fastest Binary and Text-based formats. For the .NET implementation we leverage @marcgravell excellent protobuf-net - which is currently .NET's fastest serializer. It's also the most compact which makes it an ideal choice in performance sensitive areas, e.g. transferring binary data or a large dataset as efficiently as possible.
Message Pack is another fast binary serializer that thanks to its simplicity and speed is a popular choice amongst Open Source libraries and frameworks that has bindings for most popular languages.
Its schema-less format modelled after JSON that instead uses a compact binary encoding. Despite its name it's a better Binary JSON than BSON as it's faster, smaller and doesn't include foreign artefacts BSON has.
Because of its schema-less design it's able to work with un-attributed POCOs, unlike ProtoBuf which requires each DTO property to be attributed with a numerical index.
Bundler is a fast, cross-platform, command-line runner (easily integrated into existing IDEs) optimized for ASP.NET MVC that statically compiles, minifies and combines your less, sass, css, coffee and js files.
- Uses the popular and well-tested libs in node's npm, for all minification and compilation
- Easy to use! All .bundle's are plain text files which just contain a list of the file names
- Integrates with VS.NET and MVC! Saving any supported file auto-runs Bundler. Works seamlessly behind-the-scenes while you code
- Runs outside ASP.NET context so client scripts can be re-compiled without restarting your project
- Can be used with any web project (not just .NET)
- All done at compile time, no runtime deps needed
The optimal way to call ServiceStack services is to use any of the typed generic C# Service Clients. Consuming 3rd Party REST APIs historically hasn't been a great experience as it relies on the legacy WebRequest which is versatile but also suffers from exposing an out-dated and unpleasant API for your app code to use.
Rather than the normal .NET approach of wrapping Web Request inside a suite of proxy classes, we instead encapsulate redundant boilerplate behind extension methods with opt-in features behind named params, DRYing common patterns behind terse, chained APIs.
This leaves a pleasant and intuitive API that allows most HTTP clients tasks in a single readable chained expression. It remains versatile as it allows overriding default behavior and access to the raw HTTP Request and Responses using filters and named params.
In order to provide the most productive and frictionless end-to-end development experience you need a great client story, and ServiceStack's generic and typed .NET service clients are best-in-class.
As a side-effect of the inherent benefits in our message-based design, we can provide .NET's most succinct, end-to-end typed API without any code-gen or post-build steps. You're able to re-use the code-first DTO's services were defined with, as-is, inside clients.
This has many benefits, client/server DTO's are kept in sync, you're not reliant on black-box tooling, message-based DTO designs are more resilient, and support the natural evolution of services. It's inherently simpler with less friction as client and server call-sites have symmetrical parity as the same DTO the client sends is transparently hydrated into services on the server.
A fast, unified and integrated replacement for WCF, WebAPI and MVC
- Holistically constructed to reduce artificial complexity. Services are designed for maximum re-use
- Develop with idiomatic code-first C#, features naturally bind to and empowers your existing models
- POCO models can be used in all libraries as-is - offering un-precedent levels of re-use unseen in .NET
- Easy-to-use. Never read another text-book to learn how to use another heavy .NET framework again!
- Get an overview in the introduction slides
- Read the documentation.
- Install via NuGet and start developing today!
- The example projects are highly recommended
Latest Tweets from @ServiceStack:
Install ServiceStack from NuGet
ServiceStack with Razor Support: Create an empty ASP.NET Web or Console Application and (.NET 4.0+)
PM> Install-Package ServiceStack.Razor
ServiceStack binaries only: Minimal installation of ServiceStack containing only the core-binaries (.NET 3.5+)
PM> Install-Package ServiceStack
Starter templates with pre-configured AppHost and basic Hello World REST services
ServiceStack with ASP.NET: Hosted at / - Create an empty ASP.NET Web Application and (.NET 3.5+)
PM> Install-Package ServiceStack.Host.AspNet
Side-by-Side with MVC: Hosted at /api - Create an empty MVC Web Application and (.NET 3.5+)
PM> Install-Package ServiceStack.Host.Mvc
Razor Rockstars - Showcase of ServiceStack's HTML, Razor and Markdown Support
Twitter Bootstrap Api + ServiceStack + MVC3 + Backbone.js + Bundler, Single Page App
Imgur-like image uploader, generates image resolutions for all iOS devices
GitHub-like browser to manage remote filesystem over REST
ServiceStack Docs - pushState enhanced Documentation website built with Markdown Razor
StackOverflow clone created entirely with Redis and jQuery
ServiceStack features using the real-world Northwind dataset
Backbone.js TODO app with Redis and REST backend
The Redis Admin UI - visually manage your data in Redis
Movie Rest - REST API Log for managing Movies