TracNav
OpenRasta's Documentation...
- Release Notes
- FAQs
Downloading/Building OpenRasta...
- Download from source
- Download the binaries
- Run the test suite
- .NET versions support
Using OpenRasta...
- Configuration how-tos
What you need to know about dependency injection...
- Using Castle as the IoC container
- Using Ninject as the IoC container
Tutorials...
- Building your first OpenRasta website
- Creating views with no code-behind
- Writing handlers
- Using model binders?
- Implementing a Codec
- Extending OpenRasta with a Contributor
WebForms...
- Using multiple views for a resource
- Linking a URI to a static WebForm
Deployment...
- Installing OpenRasta on IIS
- Files required for production deployment?
Building web-sites with OpenRasta...
- Supporting clients that only know GET and POST?
Reference...
Hosting...
- Root dependencies?
- Available dependencies
Configuration...
- ResourceSpace.Has
- ResourceSpace.Uses
Modules...
- SharpView
Pipeline...
- Pipeline contributors
- Well-known contributors
- PipelineContinuation members
Resources...
- Linking to resources
Handlers...
- Handler method selection
- Defined OperationResults
Binding...
- Object binders
- The default resource binder?
- ChangeSet<T> support?
Codecs...
- The Webforms Codec
- The XmlSerializer codec
- The JsonDataContract codec
- The XmlDataContract codec
Building Codecs...
- Building a media type reader
- Building a media type writer
- MediaType attribute
- Implementing configuration for ICodec
- Supporting binders and ChangeSet<> in a codec?
OpenRasta
Introduction
OpenRasta is a resource-oriented framework for .NET enabling easy ReST-ful development of web sites and services. OpenRasta is designed to run on .net 2.0 and above, and can co-exist peacefully with your existing ASP.NET and WCF deployments.
OpenRasta is also free, and ships with an MIT license. You are explicitly allowed to do whatever you want with the code, including shipping it as part of closed-source software. No cost involved, no hidden agenda, free for all.
Because OpenRasta is built on best practices, it is by far one of the most extensible frameworks, with more than a dozen extensibility points. Don't like something in OpenRasta? You can change every aspect of its behavior.
A quick start for the impatient
We do recommend you have a quick look at the "Nuts and Bolts" section below. If you really can't wait, however, jump right in with the first tutorial. It's full of examples from the whole gamut of OpenRasta goodness.
The nuts and bolts of OpenRasta
OpenRasta relies on three concepts: Resources, Handlers and Codecs.
A resource is a type that has a URI. When you configure your URIs in OpenRasta, you associate a resource type with the URI to which it belongs.
When an HTTP request comes in, the URI is matched to a resource handler (the equivalent of a controller in MVC-style frameworks). In OpenRasta, handlers are POCO classes that need only implement a method matching the name of the related HTTP method or decorated with an attribute for that HTTP method. To implement retrieval of a resource, a simple method of the form public Customer Get() is all you need to get started. The framework imposes no inheritance chain.
The object (resource) returned by the method will be rendered by a codec. You can register many codecs on the same URI to render the same resource (such as data for a customer) in XML, JSON and HTML via WebForms. The client decides which codec is used through HTTP content negotiation based on the HTTP Accept header, or optionally, file extensions (by using UriDecorators?).
Why choose OpenRasta?
Because of this very simple model, adding new URIs, new resources and new content types becomes much easier. And there's much more! Thanks to the application of development best-practices, OpenRasta is a great framework to work with.
Separation of concerns is enforced throughout the framework by separating the handling of resources and their rendering. This means less breakage in your code, looser coupling and code which is easy to navigate and read.
Loose coupling and dependency injection are at the core of the framework, helping you implement your architecture faster and more effectively. Want access to the request data? Simply add IRequest to your constructor. OpenRasta ships with an IoC container, and lets you use your own too.
The open-closed principle has been followed to allow you to extend and change the framework without having to rewrite its code or build from sources. How many times have you had to launch Reflector when building ASP.NET applications? Thanks to it's many extensibility points, you won't need to any more.
Because there's no postback, there's no strange page lifecycle to deal with. Everything becomes easier, your code gets cleaner and simpler.
Thanks to OpenRasta's innovative codec model, you don't have to use two different frameworks, one for your web pages and one for your services. By using a unified API, you reduce the time and knowledge your team needs to acquire before becoming productive.
And because of the use of interfaces, the lack of inheritance chain and the support for IoC containers out of the box, your code can be tested very easily.
Investing a lot of time and money in building an application on top of ASP.NET means that you will not be able to easily take your code and run it in a different environment. With OpenRasta's hosting support, you can start coding in ASP.NET, run your integration tests in-memory and host your code in a windows service - all without having to change your code.
Other advantages of OpenRasta:
- Support of HTTP features through a straight-forward API
- Clean separation of resource handling and representation
- Extensible codec support, including JSON, XML, WebForms, SharpView and SparkView.
- Serve XML and JSON transparently from the same URI, using content-type negotiation or file extensions.
- Out-of-the-box support for coding XHTML 1.1 compliant websites
- Create links to any resource with one simple method call
- Rich URI support for user and search-engine friendly URIs
- Built around an IoC container, and supports using your own container
- POCO resources and POCO handlers. No inheritance!
- Can be hosted on ASP.NET, in memory or on http.sys. There is no dependency on ASP.NET.
- Did we mention it's completely and absolutely free?
Comparing OpenRasta with other frameworks
Out of the box, OpenRasta is the only framework providing all those features, without any additional work.
| Feature | OpenRasta | asp.net MVC | WCF ReST |
| Rich centralized URI routing | Yes | Yes | Partial1 |
| Easy URI and links creation | Yes | Partial2 | No |
| POCO over inheritance | Yes | No | No |
| Fluent configuration API | Yes | No | No |
| Dependency Injection and IoC | Yes | No3 | No3 |
| Supports multiple formats on the same URI | Yes | No | No |
| Build rich object graphs from forms | Yes | Partial4 | No |
| XHTML 1.1 html helpers | Yes | No | No |
| Extend or replace infrastructure components | Yes | Partial5 | Partial6 |
| HTTP Digest authentication without AD | Yes | No | No |
| Extensible asp.net compiler | Yes | No | No |
| Clean separation of resource handling and rendering | Yes | No | No |
| Out of the box support for other containers | Yes | No | No |
| Open-source, accepting patches | Yes | No | No |
| Support for all the HTTP verbs | Yes | Yes | Yes |
| Supports returning any HTTP status code | Yes | Partial7 | No |
| Runs on .net 2.0, 3.0 and 3.5 | Yes | No (3.5) | No (3.5) |
| Can run in-memory without http | Yes | No | No |
| Can run in http.sys | Yes | No | Yes |
| Supports handler/controller/service polymorphism | Yes | No | Yes |
- Relies on attributes per-method
- ASP.NET routing can create uris from key/value pairs, but not from nested object properties
- While other frameworks can be retrofitted to use containers, it's a one-way operation only, with the framework calling the container. OpenRasta is built around a container, resulting in all its components being accessible from your code through dependency injection.
- Doesn't support interface types or indexers
- Only supports modifying controller builders and view engines
- Modifying components in WCF ReST is not a simple story. It involves custom behaviors and ServiceHost implementations.
- MVC only comes with a few ActionResult? types. To support more status codes, custom ActionResults need to be implemented.
