David Kennedy’s Tech Ramblings

Just another WordPress.com weblog

MVC Discoveries (from my desktop notepad files :P) August 12, 2008

Filed under: Uncategorized — dotnetdave @ 5:30 am

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$)

General reminders:

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!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s