This project is read-only.

Using Handler events to stop an item from being loaded

Topics: Customizing Orchard
Oct 15, 2012 at 6:36 AM
Edited Oct 15, 2012 at 6:37 AM


I am trying to restrict a content item from being loaded based on certain permissions. I am able to restrict the item from being displayed by using the Permissions and extending IAuthorizationServiceEventHandler. But the problem I am having is the pager in the admin list view being wrong. So it would be better if I could stop the item being loaded in the first place.

So would like to know if its possible to user the OnLoaded or Loading events in the handler to stop the item from being loaded.


I am using version 4.2. I think in version 5.1 they have contentitem level permissions but I am not in a position to upgrade at the moment.



Jan 5, 2013 at 4:28 PM

I don't know if that's possible, but since all content is loaded through IContentManager, I suppose you could implement your own version of it, checking permissions when loading content. You could even derive your own version from DefaultContentManager, override the Get methods, implement your security requirements, and invoke the base methods if permission is granted.

However, if you can, I would upgrade to 1.6 and see if the new contentitem level permissions suit your needs.