Restrict Action to a Particular Type of HttpRequest in Castle MonoRail

This is one of those things that apparently everyone just knows, but I didn’t, and haven’t, for the past 3 months of doing MonoRail development. Color me stupid. Hopefully someone else out there can benefit from this.

If you want to restrict a certain action to only be available via a particular type of http request (POST, GET, etc), all you have to do is add an AccessibleThrough attribute to your action, like so.

[AccessibleThrough(Verb.Post)]
public void Delete(int id)

Yup, that’s it! I started down this path of parsing strings and case insensitive comparisons all the while thinking "This has got to be easier". Turns out it is.

This entry was posted in Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>