BT

InfoQ Homepage News ASP.NET MVC 2 Brings Breaking Changes

ASP.NET MVC 2 Brings Breaking Changes

Bookmarks

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
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.

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

Community comments

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

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

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.