Click here to Skip to main content
12,951,983 members (57,539 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 11 Oct 2013


, 11 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
OpenRasta is an open-source .NET framework for building everything web, from web sites to RESTful APIsWhy OpenRasta?OpenRasta relies on three

Editorial Note

This articles was originally at but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

OpenRasta is an open-source .NET framework for building everything web, from web sites to RESTful APIs

Why 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).

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.
  • it is completely and absolutely free


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ASP.NET Community
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

765 members

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid