Gray's Matter
Justice Gray - North America's favorite metrosexual software consultant

I Wish These People Updated More Than Once a Year

The New Captain America
For those of you who come for the lack of content, the new Captain America will keep you entertained

My apologies in advance for the dryness of this post, but given that some of Codivation's current contracts are using this technology right now, I wanted to capture some of this down for reference.  Yes, that's right, one of the perks of running your own company is being able to negotiate some control over technical decisions!  I know what you're all asking inside, and no, I have no idea why Microsoft hasn't contacted me to do white papers.  All of what you can read here can be gleaned from watching the first part of Scott Hanselman's new screencast series - however watching that screencast will take you sixteen minutes while reading this post will take you one. Except, of course, in D'Arcy's case where I expect the reading time will be approximately 2 hours before he gives up and asks his class for help. 

Here's what *you* need to know thus far about the new Microsoft MVC Preview 2:

  • The "MVC with Test Project" template is gone.  In its place, there is now a prompt on the normal MVC project (a la Monorail) that asks if you'd like to set up a test project (yay).  The only test project you can set up is keyed to MSTest (booooooooo) but they are hoping to have support for NUnit, xUnit, mbUnit and whomever else wants to play though I would suggest DUnit and JUnit shouldn't get their hopes up.  A scoop from my inside man at MS says that G-Unit might still have a chance if we petition Phil Haack for it*.
  • In the previous releases of the MVC, the entirety of the new functionality was located in an updated version of System.Web.Extensions (3.6).  However, this has now been removed from Extensions so to make the MVC bin-deployable for people without colliding with the old version of System.Web.Extensions (3.5).  In its place are the following three assemblies:
    • System.Web.Mvc - contains the Mvc namespace stuff
    • System.Web.Abstractions - contains the IHttpContext (sorry, HttpContextBase or whatnot), IResponse, IRequest, IWhatever
    • System.Web.Routing - all of the routing logic.  The routing logic is now usable in "vanilla" ASP.NET as well!!
  • Route definitions used to look like this:

    "[controller]/[action]/[id]"

    and now they look like this:

    "{controller}/{action}/{id}"

    Truly a breaking change no site will ever recover from!
  • Controllers no longer have a [ControllerAction] attribute.  Any public method on the Controller is available through the web. 
  • However, if you have any *other* public methods on the Controller that you want available for unit testing but do not want to be accessible through the web routing, mark them with a [NoAction] attribute.
  • Much more detailed exception messages are available when a controller fails to load, and particularly when a View cannot be found (you'll get a message stating "View cannot be found at the following paths:")
  • MS MVC can now run in partial trust environments.

Continued tomorrow on related topics but with even less related pictures!

[update: the other three parts in this series can be found by clicking below:
MVC Preview 1 to Preview 2 Part B
MVC Bombshell #1
MVC Bombshell #2]


* I can't take full credit for that one - it came from a presentation on unit testing that EDMUG's treasurer (Brad Daoust) and I did a couple of years back.  I'm only providing this disclaimer so Brad doesn't sue!

Thursday, March 06, 2008 #

3/6/2008 5:02:29 AM (Mountain Standard Time, UTC-07:00)
There's only a template for MSTest in the new File | New MVC Project wizard right now because we're reaching out to the big Unit Testing libraries to get them to help create templates. If you have a Unit Testing Library, you can get into the MVC File | New Project dialog by packaging up your templates like this: http://blogs.msdn.com/webdevtools/archive/2008/02/18/asp-net-mvc-test-framework-integration.aspx

I'd guess/hope that the installers for the major libraries would just include their templates in their next versions.
3/6/2008 5:37:56 AM (Mountain Standard Time, UTC-07:00)
BTW, we have added MbUnit templates with ASP.Net MVC integration. It's all set up and ready to go!

Grab the latest MbUnit v2 and v3 previews from here: http://code.google.com/p/mb-unit/
3/6/2008 6:42:58 AM (Mountain Standard Time, UTC-07:00)
Thanks for the comments guys. I'll make a note of this in part B!
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):