For those of you who come for the lack of content, the new Captain America will keep you entertainedMy 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!