MVC CAPTCHA for Preview Release 3

Since 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 how they changed the MVC CAPTCHA for the better. Originally in MVC Preview Release 1 for the MVC CAPTCHA many of you remember that the indicator for a valid CAPTCHA was passed through the parameters of the action method like so: [ControllerAction] [CaptchaValidation("captcha")] public void Register(bool captchaValid, string otherParameters) { // do stuff } However when Preview Release 2 came out the ability to pass the parameter through the action method was broken. So I had to create a hack around this: ...

June 24, 2008 · 3 min · 575 words · Nick Berardi

MVC + Facebook == Wonderful Development Platform

Just recently I started experimenting with the ASP.NET MVC Framework and the Facebook Development Platform, it has been a very bumpy road, but I have ironed out some major issues that I would like to share with you today. I will start with a little history of what I am trying to do. For about a month and a half I have had one of my IdeaPipe interns, Dimitry, experimenting with creating a FBML (Facebook Meta Language) Application with MVC. MVC is an ideal platform for FBML because with MVC you have total control over your markup which is needed to have a lean FBML application. I am not going to go in to the differences of developing an FBML vs IFrame Facebook Application, because that information is easily found with a Google Search. What I am going to talk about is the hurdles I overcame and the custom software I had to develop to get MVC working smoothly with Facebook. ...

June 6, 2008 · 4 min · 653 words · Nick Berardi

ASP.NET MVC Preview 3 Released

The ASP.NET MVC Team has released an refresh of MVC. To all those that are interested the new Preview Release is posted at: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=13792 The new release contains many new features over the 2nd Preview Release and the Interim Release from a month a half ago. In this post I am going to outline the features that are new from the Interim Release to Preview Release 3. Action Method and Result Changes As you remember from the previous release, you are now required to return an ActionResult. Many of the ActionResults were renamed to the following types: ...

May 27, 2008 · 4 min · 782 words · Nick Berardi

ASP.NET MVC Interim Released

The ASP.NET MVC Team has released an refresh of MVC. To all those that are interested the new Interim Release is posted at: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=12640 The new release seems to rely on a non-CodePlex open source project. Is this the first sign of Microsoft’s commitment to open source? http://code.google.com/p/moq/ The Release Notes have a lot of good information about new features and bug fixed included in this release: This CodePlex refresh of the ASP.NET MVC source code includes a number of key changes and refactorings. To see a full list of API changes, take a look at the attached zip file produced using Framework Design Studio. ...

April 16, 2008 · 3 min · 502 words · Nick Berardi

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 allows POST to 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 are OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, and CONNECT. 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 ...

April 13, 2008 · 2 min · 358 words · Nick Berardi

Creating a Facebook Application using MVC

Facebook has been growing in popularity ever since it was released on February 4th 2004 at an almost unstoppable pace. Up until May 24th, 2007, it wasn’t much different than MySpace (or insert your favorite social network here), however on that day they rolled out a SDK that turned Facebook from a destination website to a platform that let any developer interact with their almost 71 million users. You can read more about the history of Facebook at Wikipedia. ...

April 11, 2008 · 4 min · 720 words · Nick Berardi

Force MVC Route URL to Lowercase

So one of my pet peeves in web development is mixed case URL’s. And I usually make sure that all my URL’s in my personal projects follow this standard. I also believe, contrary to my URL case standard, that my code should follow standards .NET naming techniques, such as Pascal casing for my method names. These two naming standards come in to conflict with MVC because the name of the action method in the controller is used in its native Pascal case. Which generates URL’s that look like this: ...

March 31, 2008 · 2 min · 234 words · Nick Berardi

Is MVC Right For Your Application?

There is a simple way to tell if you can use MVC in your web application. If any of the following are true, you probably shouldn’t: You require the ViewState This includes any 3rd party control… Quick way to check this is disable ViewState and check to see if you application works as expected. You require post backs This usually is required by Web Forms or Microsoft AJAX Toolkit… Fortunately most of the post back functionality can be duplicated on the client side with AJAX. I fine jQuery makes a real easy job of this. So that is all that you need to ask your self when thinking of upgrading or deciding which route to take when planning your new application.

March 16, 2008 · 1 min · 121 words · Nick Berardi

ASP.NET MVC: Securing Your Controller Actions (The .NET Framework Way)

So I just read Rob Conery’s blog post on Securing Your Controller Actions in MVC. I was a little perplexed about why guys at Microsoft love to reinvent stuff they have already done. I know Rob Conery is a really smart guy and has a wonderful grasp of the .NET framework, so I would have to assume he knows about what I have outlined below. My only guess is that he just wanted to re-invent something that is already built in to the framework using his own code. ...

March 13, 2008 · 3 min · 461 words · Nick Berardi

ASP.NET MVC Preview 2 CAPTCHA using ActionFilterAttribute

My last article on ASP.NET MVC CAPTCHA was very well received by many of my readers and it even caught the eye of the DotNetKicks crowd. Now that MVC Preview 2 was released last week, many new features make encapsulating my CAPTCHA control even easier. Most notably is the ActionFilterAttribute which allows you to override the Pre and Post action events for any action the attribute is applied to. Basically everything works the same as it did in the previous article. I just modified things for MVC Preview 2. To validate the CAPTCHA you add the attribute CaptchaValidation to the action. ...

March 9, 2008 · 1 min · 203 words · Nick Berardi