Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com

Typing the RenderView method in ASP.Net MVC

Since the first minutes I started playing around with the MVC framework something has bothered me about the use of magic strings in regards to the RendorView methods.

With the current implementation of RendorView there is NO compile time type checking to ensure that view even exists (evil magic strings). Also, there is no way to find all usages of a view without doing a 'global find' on the project.

If you can strongly type the view to be used you will benefit from compile time type checking, you can use ReSharpers 'Find Usages' and it is just less evil.

Using the ViewBase as CodeCamp does assumes i want to use the SmartBag as my Viewdata. As of now, i am leaning more towards using typed objects for each view. a so called ViewModel if you will.

Matt Hinze
wrote
re: Typing the RenderView method in ASP.Net MVC

on 03-10-2008 1:52 PM

Of course I like it and this is better than magic strings. I am still struggling with the problems that SmartBag attempts to fix, specifically global data for ViewUserControls, but I haven't delved into the latest bits so I may be lagging a bit.