BT

ASP.NET MVC 2 Brings Breaking Changes

| by Jonathan Allen Follow 595 Followers on Mar 18, 2010. Estimated reading time: 1 minute |

A few days ago Scott Guthrie announced the production release of ASP.NET MVC 2. With it comes with many new features, but also some breaking changes. Compared to the rather strict rules around changing .NET’s base class library, the changes in ASP.NET MVC are almost caviler.

First up is IDataErrorInfo. This woefully under-documented interface has been in .NET all along, but lacks any sort of guidance on its use. In ASP.NET MVC 1 only properties that are changed will be checked for validation errors. In version 2, every property is checked during a validation cycle, which makes it quite a bit less error prone. Also, the class-wide validation will no longer occur if any of the property-level validations fail.

Html.Substitute, which is used to create uncached fragments, is no longer supported due to changes in the MVC view engine. This means anyone relying on partial caching needs to reevaluate their design.

IValueProvider replaces all uses of the much heavier IDictionary interface. According to the documentation “this change affects only applications that include custom value providers or custom model binders.”

Help methods now return MvcHtmlString instead of normal strings. This was necessary in order to support the new HTML Encoding Block syntax in ASP.NET. In both classic ASP and ASP.NET, developers were used to using <%= expression %> to mix static and dynamic content. Unfortunately it is prone to HTML-injection errors. With ASP.NET 4, developers can use the new syntax <%: expression %>. This guarantees that any string is automatically HTML encoded. If you don’t want encoding, the expression must return an IHtmlString.

Changes to the DefaultControllerFactory class require matching changes to custom controller factories, which are normally used for dependency injection.

Finally, the string “area” is now considered to be a reserved word when dealing with URL routing. This was done to support the Areas feature added in MVC 2.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT