Simple REST API Versioning Using MEF and MVC

I know that is a whole host of acronyms in the title, so let me explain. Recently it came to my attention at my day job that I was going to have to support two versions of our API simultaneously. This information came as no surprise to me, but unfortunately it wasn’t something I originally planned for when carefully laying out the URL patterns for the REST API. Since I was going to have to yank the current code apart to support the new API in parallel with the previous API, I decided to do things right and put a wish list in place for what I wanted to accomplish with the next version of the API: ...

September 8, 2010 · 4 min · 772 words · Nick Berardi

ASP.NET MVC 3 Preview 1 Released

The title says it all, so go get your copy today and check out all the new features. You can download it here. New features include: Razor View Engine Dynamic View and ViewModel Properties “Add View” Dialog Box Supports Multiple View Engines Service Location and Dependency Injection Support Global Filters New JsonValueProviderFactory Class Support for .NET Framework 4 Validation Attributes and IValidatableObject New IClientValidatable Interface Support for >NET Framework 4 Metadata Attributes New IMetadataAware Interface New Action Result Types (HttpNotFoundResultAction and HttpStatusCodeResultAction) Permanent Redirect Support in the controller (RedirectPermanent, RedirectToRoutePermanent, and RedirectToActionPermanent) Looks like this is going to be a very worth while upgrade, and a special thanks should be given to Phil and team for making ASP.NET MVC everything that ASP.NET WebForms isn’t.

July 27, 2010 · 1 min · 124 words · Nick Berardi

Creating Your First MVC ViewEngine

A question that I have been hearing a lot lately is: How do I change the view location in MVC? But what they really mean to say is: How do I create a new ViewEngine that uses the view locations of my choosing? It is actually very simple to do, and once you see it, I think you will agree with my assessment. The first thing we are going to do to create our custom ViewEngine, is define the paths that we want to use for our master pages, view pages, and shared pages. I have taken the liberty to define the following paths, you can customize them however you wish: ...

May 11, 2009 · 4 min · 773 words · Nick Berardi

ASP.NET MVC Has Changed My Life

Lately I have been neglecting my blog and not posting as often as I would have liked. I have had some very exciting things start up, at the begining of the summer, in my life that 6 months ago I would have said “no way is that going to happen.” These new adventures are the growing popularity of my blog, public speaking engagements, and a new book I was asked to write on ASP.NET MVC. Many of you picked up on the fact that I was writing a book based on my profile on the Philly.NET website, but I had officially announced it until this post. Many of my friends and family don’t even known I am writing a book so feel lucky in knowning you guys are some of the first people to know. ...

October 28, 2008 · 4 min · 771 words · Nick Berardi

ASP.NET MVC Goes Beta (Part 2)

From what I can tell ASP.NET MVC Beta is just ASP.NET MVC PR5 with a couple bug fixes. So the good news is that the interface has finally solidified and we shouldn’t see anymore breaking changes before the final release. New features: MvcFutures.dll is not included in the beta (as it wouldn’t be included in the final release) The Beta installer installs the ASP.NET MVC assemblies (System.Web.Mvc.dll, System.Web.Routing.dll, and System.Web.Abstractions.dll) into the GAC. New Simple Membership Features in the Default Project Template New Filter Types for Authorization and Exception Handling New Output Cache Filter Changes for ASP.NET AJAX Namespaces in Routes New Interface for Enhanced Testability of TempData ActionInvoker Extensibility Improvements ViewDataDictionary (minor change) ViewEngine Improvements Helper Improvements Controller and Filter Improvements Bug fixes: ...

October 16, 2008 · 2 min · 303 words · Nick Berardi

ASP.NET MVC Goes Beta

Wow has it really been 10 months since I first started using MVC. We have hit our first beta today. No information about what has changed, I will make sure to keep you all updated. But get it while it is hot: http://www.microsoft.com/downloads/details.aspx?familyid=a24d1e00-cd35-4f66-baa0-2362bdde0766 For everybody who hasn’t heard of MVC, how couldn’t you have heard about it now if you are a regular reader of my blog. But for all the new people visiting, here is an overview: ...

October 16, 2008 · 2 min · 271 words · Nick Berardi

jQuery and Visual Studio Shipping Together

I have been a huge fan of jQuery ever since I started working on IdeaPipe about 10 months ago. Mostly because of its simplistic DOM access using standard CSS syntax that we all have to learn anyways in the modern Web 2.0 world. In addition to the ease of finding elements on your page, it also works very nicely with other frameworks, I have used it in combination with Microsoft AJAX, Google’s GData JavaScript, and TinyMCE. ...

September 28, 2008 · 2 min · 299 words · Nick Berardi

Philly .NET User Group Meeting for September 2008

I will be presenting September 17, 2008 at Philly .NET User Group Meeting. My talk will be on: Creating a modern, web 2.0, application with MVC and jQuery with a focus on doing this in a RESTful manor. My goal is for the developers in attendance to learn how to create a RESTful website design using MVC and implement that RESTful design on the front end with some simple jQuery. These principals will be demonstrated by creating a simple Twitter like application for sharing messages. All the source code will be available via my website at http://www.coderjournal.com after the presentation. ...

September 11, 2008 · 3 min · 475 words · Nick Berardi

ASP.NET MVC Preview Release 5

Looks like the MVC team has put out preview release 5 of the MVC Framework today. You can get the latest version from CodePlex. Here is what I can tell has changed from the release notes. What’s New Added global registration of view engines Changed the IViewEngine interface to add the RenderParial method Added support for rendering partial views Added a parameter to specify a default option label for DropDownList controls Moved ASP.NET AJAX extension methods to a separate namespace Added helpers for RadioButton and TextArea controls and made overall improvements to other helpers. Removed helper method overloads to avoid ambiguity Added array support for action method parameters Removed the ActionMethod property from action filter context objects Added support for custom model binders Added an IActionInvoker interface Added an UpdateMode method to the Controller class Changed HandleErrorAttribute so that it does not handle exceptions when HttpContext.IsCustomErrorEnabled is false Added a new AcceptVerbs attribute Added a new ActionName attribute Known Issues and Breaking Changes Controller class now is derived from ControllerBase class Controller.Execute as removed, it is not called ExecuteCore. Controller initialization steps should be done in Initialize method now. IViewEngine interface is now responsible for finding views, not rendering them. Some overloads to some helper methods have been removed. AJAX helper methods have been moved to a new namespace. This version is incompatible with Visual Studio 2008 SP1 Beta Upgrading from Preview 4 to Preview 5 System.Web.Abstractions and System.Web.Routing have been changed to version 3.5.0.0 Assemblies are located at %ProgramFiles%\Microsoft ASP.NET\ASP.NET MVC CodePlex Preview 5 Derik also noticed that many of the classes are still sealed, and is requesting that the team un-seals all classes, and I agree with him. ...

August 29, 2008 · 2 min · 326 words · Nick Berardi

Using a Parameter Attribute to set a Default Value in MVC

A couple days ago I came across a breaking change in ASP.NET MVC PR4 that wasn’t reported. The breaking change is that defaults from routes are no longer used as defaults for parameters in the action method, if no appropriate parameter is found in the request. Basically what this means is the following: I have the following route: URL: /home Controller: Home Action: Index Defaults = page: 1 I set the page so that it always defaults to “1” if no value is found in the query string for “page”. So when a request is executed, the Route passes back the RouteData.Values = controller: “Home”, action: “Index”, page: 1. Then it goes through it’s normally processing and the value of the page’s query string is passed in to my action method for the page parameter. So if query string page = 1 then 1, query string page = 2 then 2, and so on. This is how it worked in PR3 and how I understood it was suppose to work as a concept. However, in PR4, this doesn’t work anymore because of Line 166 in ControllerActionInvoker. It specifically checks that the value is in the route values. However they are always going to be in the route values if they have been defined as a default. ...

August 13, 2008 · 4 min · 836 words · Nick Berardi