Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



Upgrading Dimecasts.Net from MVC Preview 4 to Preview 5

Like many other nerds (sorry people, lets face we are nerds :) ), as soon as I heard that MVC Preview 5 had been released I wanted to run out and upgrade Dimecasts.net. 

Let me first start off by saying this.  Anyone that decides to build a production application of any size on a Technology Preview must be willing to accept breaking changes between releases.  Please do not take this post as me 'bitching' or 'complaining'.  This post is just to help others that may be about to do the same thing.

Here are the conversion issues I ran into:

Issue #1:
Since the new assemblies are now versioned again I needed to update the web.config to reflect 3.5.0.0

Solution:
Spend 3 seconds changing the web.config

Issue #2:
The decision was made by the MVC team to remove RenderUserControl and replace it with a more generic RenderPartial.  Now they both do the same thing in principal, but act in a slightly different way.  Because RenderPartial does not return any html (it writes it directly to the output stream) you need to change the syntax to call it.

Solution:
Replace all instances of RenderUserControl with RenderPartial as well as change the syntax.

Old Syntax
<% = Html.RenderUserControl(......) %>

New Syntax
<% Html.RenderPartial(......); %> // No = sign and added ;

Issue #3:
The HTML Helper ActionLink was changed to no long support the use of generics/lambda expressions.  This was done because you can not assume route information based on generics/lambdas and this could cause issues in the future

Solution:
Make the needed and painful change all over the code.

Issue #4:
Most of the HTML Helper's for text entry (text box, text area, etc) was changed to no longer accept html attributes such as width, height, cols, etc.  This was done with good intent and was the right move.

Solution:
Now in order to supply html attributes you need to use the overload that allows you to provide an anonymous object with the information.

ie -- new { width = 25, height = 20 }

 

All in all the upgrade was not all that painful.  I think it took me about 1 hour, nothing major.  Actually took me about as long to regression test the site as it did to make the actual changes.

I hope this helps someone else that is making the change.

Till next time,

[----- Remember to check out DimeCasts.Net -----]



Comments

Ben Scheirman said:

The lambda's for Html.ActionLink still exist in Microsoft.Web.Mvc.dll ... though I understand that they might not be able to address all route (due to ActionInvoker changes) they are still very powerful for use in refactoring and compile safety.

If these end up going away I will be very tempted to drop ASPX view engine in favor of NVelocity, since it is so much more concise.

# September 3, 2008 9:21 AM

Derik Whittaker said:

@Ben,

I looked over in Microsoft.Web.Mvc, but must have missed it.  I will take a look again.

Thanks,

# September 3, 2008 9:28 AM

Nick Berardi said:

created this RegEx find and replace all the older RenderUserControl's for Visual Studio

\<%= Html.RenderUserControl\({[^\)]*}\)[ ]*%\>

with

<% Html.RenderPartial(\1); %>

# September 3, 2008 10:46 AM

Steve Gentile said:

One option is to wrap their controls inside your own.  This way, you can minimize the amount of breaking changes from preview to preview.

I used to do the same with webforms.  

I think more intuitive work needs to occur with the model binder stuff - more like Monorail does it would be preferred for me.

# September 4, 2008 12:44 PM

Dave Schinkel said:

Totally agreed.  

For example you don't build out an entire white-box  Company portal API for 5+ divisions for a mid-to-large company that has 40,000 some users based on MVC.  You wait until it's mature enough.  But if you enjoy your weekends loving your PC and no life, go right ahead.

# September 6, 2008 3:25 PM

Tim Barcz said:

Yeah this is old hat, I know.&#160; The Preview 5 release was news about three weeks ago.&#160; There

# September 22, 2008 10:55 PM

Community Blogs said:

Yeah this is old hat, I know.&#160; The Preview 5 release was news about three weeks ago.&#160; There

# September 22, 2008 11:33 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News