Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

OpenRasta

0.00/5 (No votes)
10 Aug 2013 1  
OpenRasta is an open-source .NET framework for building everything web, from web sites to RESTful APIsWhy OpenRasta?OpenRasta relies on three

This articles was originally at wiki.asp.net 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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here