April 13th, 2008
Coder Journal’s MVC Toolkit
Today I decided to release a toolkit that I have been building over the past couple of months. Most of the code in the toolkit is related to MVC. Here is a list of the features:
ActionFilterAttribute’s
- HttpPostOnlyAttribute
Only allowsPOSTto be made against the action. - CacheAttribute
Sets the action’s response as cacheable. - CompressAttribute
Compresses the action’s response using GZip or Deflate encoding. - ServiceAttribute
Marks an action as able to provide the ViewData as JSON, XML, or JSONP. - ServiceOnlyAttribute
Marks an action as only able to provide the ViewData as JSON, XML, or JSONP, that means no HTML. - ExceptionHandlerAttribute
Handles any exceptions thrown from an action, and redirects it to another page, or another action. - CaptchaAttribute
I did a whole post on providing a CAPTCHA for your MVC action. - AllowedHttpMethodsAttribute
Only the HTTP methods entered in to this filter are allowed for your action. Available HTTP methods areOPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE, andCONNECT.
ViewEngines’s
- ServiceViewEngine
This view engine provides the serialization of the ViewData to JSON, XML, or JSONP. It is set when one of the following is requested from the ServiceAttribute above.
Route’s
- LowercaseRoute
I did a whole post on why I needed this in my toolkit. Mostly because of my obsessions to have all URL’s in lowercase.
Method Extensions
- Redirect extends HttpResponse
I have had a long standing discontent with the Redirect method of the ASP.NET. I have talked about good use of HTTP Status Codes before. There are at least 3 status codes that you want to consider before choosing a response status code of 302. Just to reiterate my post on the subject use 303 to redirect from a form POST, use 307 when you want to redirect to a page that is going to change with each request, use 301 if you want to permanently redirect one URL to another.I created the, Redirect, extension method on HttpResponse so that the status code could be set for the redirect.
View Source: Coder Journal MVC Toolkit Source
Download Binary: Coder Journal MVC Toolkit Binary
Update: I have updated one bug found. Both links above contain the updated source and binaries.








April 13th, 2008 at 12:08 pm
Coder Journal’s MVC Toolkit…
You’ve been kicked (a good thing) – Trackback from DotNetKicks.com…
April 13th, 2008 at 11:31 pm
Excellent! Thanks for posting this – I’ve followed your posts – having this in collected into a library is so useful!
April 14th, 2008 at 3:18 am
What about some credit to the creators of the code?
Compress & Cache Attribute = http://weblogs.asp.net/rashid/archive/2008/03/28/asp-net-mvc-action-filter-caching-and-compression.aspx
Your toolkit is quite nice, but at least you could provide a comment that tells where you got the code from.
April 14th, 2008 at 6:08 am
Kenneth,
Thanks for alerting me to that. I can’t remember where I picked up some of the code sometimes. I have updated the code with a link back to Kazi Manzur Rashid’s site.
Nick
April 14th, 2008 at 8:33 am
[...] Coder Journal’s MVC Toolkit – Nick Berardi’s Coder Journal [...]
April 17th, 2008 at 12:30 am
[...] Coder Journal’s MVC Toolkit – Nick Berardi releases his set of tools to help support MVC, containing a number of Action Filter Attributes, along with a view engine and additional route support- Full source and binary distributions available. [...]
April 18th, 2008 at 6:34 am
Weekly Web Nuggets #8…
General IoC Containers Benchmarked : Torkel Ödegaard benchmarks the hottest IoC containers for .Net, including Microsoft’s new Unity container. The takeaway: the performance is negligible – usability for you should be the most important criteria. The …
May 9th, 2008 at 6:38 am
[...] for Cache, GZip Compression, CAPTCHA, HTTP POST Only. And an attribute to provide serialiread more | digg [...]
June 24th, 2008 at 7:08 am
[...] my last release of the MVC toolkit some major changes have taken place in the MVC Framework. I am going to do a quick run through of [...]