After having lived in WinForms & back-office web services land for so long I’m a little bit rusty, and with the changes to the MVC framework having been significant between the 4 pre-releases its made for an up-hill battle. Mostly for my own personal benefit, I’ll dump a few pointers here that I’ve found helpful or could have saved me some time a couple of weeks ago.
To start with, I gained a great deal from ScottGu’s blog posts regarding the framework:
also the screencast from Scott Hanselman was useful, available from:
Recent changes in the Pre-release 4 preview:
ControllerActionAttribute gone – any public method on Controller classes will be exposed
RenderView method replaced by ActionResult return for Controller methods (RenderView has been changed from public to protected for reasons known to M$)
Load up ViewPages from the Page_Load() event (with AutoEventWireup=true, the default), NOT the constructor! This seems blindingly obvious to me now, but it still took me a little while before I twigged to this one.
When you kick up a debug session out of VS2008 while in either the code or designer file for a ViewPage, it defaults to adding the ‘.aspx’ extension. With IIS7 & the MVC routing, this doesn’t work. You need to hit the path without the ‘.aspx’ extension, and let the MVC routing & controllers take care of the rest.
This at least got me up and running & able to add my own ViewPages to an MVC site. Happy MVCing!