Recent Posts and Articles
Anti-forgery tokens are a very important security feature of ASP.NET MVC and Orchard. Most of the time, you should keep them in place, and just let the system work its magic. There are a few rare situations however where it’s not the appropriate protection and you’ll want to disable it. Being too lazy to include the token in your ajax requests or your forms is of course not one of those situations.
Building WebAPI controllers in Orchard is fairly simple: just inherit from System.Web.Http.ApiController. You’ll then be able to inject dependencies exactly in the same way that you would anywhere in Orchard. WebAPI is designed so that the default behavior is that a controller represents a category of resources, such as a product, an article, etc. There’s a bunch of conventions in place so that just naming the methods on the controllers is enough to wire them up. If this REST-like behavior is what you’re after, that’s great, just apply the conventions and you’re good to go. If you need to stray from that model, and implement something closer to what you’d do with a regular MVC controller, you’ll need to do a little more work.
A video post explaining the Multitenancy Module and showing how easy to setup and manage a multitenancy site and how useful it can be to you.
- Status: Sipke is still working on the Layouts feature, Piotr refactored ICacheService to be more generic, Redis cache module had a few changes/fixes, Piotr is working on IIS-integrated background tasks, Orchard.Cache is modified by Lombiq to use the .NET MemoryCache instead of HTTP cache, Identity is now fixed for content items to match one identity instead of all of them by Bertrand (see his blogpost on the topic), Stanley added a feature for filtering content per user for the TagCloud, Brett extended Orchard.OutputCache so that authenticated requests can be cached too.
- To see the continuous builds and their results for the Orchard source, visit http://teamcity.codebetter.com and log in as guest.
- Abhishek will present at a workshop in Mumbai about Orchard.
- Demo by Zoltán - Tidy Orchard Development Toolkit: an Orchard module that makes it possible to separate your own modules and themes from the original Orchard source. This way you can store the Orchard source you're working with in one central place and use it for different projects.
- A related matter is that in 2.0, some changes will (hopefully) be made to make it easier to work with the Orchard source as a sole developer and in a team too, but the details are still in question.
- Demo by Sipke - content rollback: AuditTrail now provides an action to rollback a content item to a previous state.
- Sébastien's idea to enhance Background Tasks: Background Task Groups. Adding an Attribute defining the group to your Background Task would make it run in that group to separate BGTasks preventing certain tasks blocking others. BGTaskGroups' run intervals to be stored in HostComponents.config.
- Status: Projection Pages are now Listable by default, Nick and Sébastien are working on their feature branches, TaxonomyService is refactored and contains API-documentation, the MissingSettingsBanner for Email settings was causing a performance bug in OutputCache which is now fixed.
- Stanley was given write access to the Orchard repository, congrats!
- Demo by Sipke - updates to Dynamic Forms: client-side validation support for fields is several ways (integrated wit MVC validation). We had a long discussion regarding possible changes and improvements.
- Demo by Benedek: a PowerShell script (soon to be open-sourced as part of the Orchard Dojo Library) to check the consistency between the content of .csproj files and the file system both ways.
- Announcement by Benedek: the translations of the Gallery themes and modules are moved to a different project on Crowdin.
- Demo by Zoltán - Orchard beginner walk-through on TryOrchard: the "Try Orchard!" sites on DotNest now display tips and a walk-through aimed at beginners with Orchard on the front-end and the Dashboard.
- The new theme for the Orchard community sites are still work-in-progress by Shaun.
There’s a number of differences between regular MVC controllers and WebAPI controllers that make the latter much more suitable to building APIs: they are REST-centric, they can negotiate the format of the answer, etc. Implementing WebAPI controllers in Orchard is really simple. First, you need a route, and that will be the subject of this post.
Whenever you need to get the URL of a ASP.NET MVC action, you should use Url.Action (where URL is an instance of UrlHelper), and never hard-code the URL. This way, the URL is dynamically constructed from the available information in the Url.Action parameters and in the route table. If the route is changed, the results of the Url.Action call will change accordingly, and everything will continue to work. The same principles, of course, apply to WebAPI actions.
There are rare cases where you’ll want to be able to inject instances of classes that don’t implement IDependency. One example of this can be found in MvcModule in Orchard.Framework, which also provides a good example of how to do it. The idea is to derive from Module, and override the Load method to register factories for the types you want to expose: