Update from MVC3 to MVC4

In ELMA 3.9 the ASP.NET MVC library was updated from version 3 to version 4.

To update the module to version MVC4 follow these steps:

1. Update project libraries and configurations according to http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806.

In the System.Web.Mvc version number specify 4.0.0.1 instead of 4.0.0.0.

2. Collect and check the module functionality. Below are the most frequent markup compilation errors:

  • Using variables like @someVariable inside a started code block – remove "@" and leave only the variable name.
  • Sometimes you need to replace markup output from @Html.RenderSomething() to Write(Html. RenderSomething()) – mainly it is required in template functions and delegates.
  • In version MVC 4, standard extension-function Html.NameFor was added, while we had a similar function. We had to delete our function, since otherwise views could not be compiled. But the function result changed from string to MvcHtmlString and now when using this function you may need to add ToString().
    E.g. Html.NameFor(m => m.PropertyName).ToString().
  • Some keywords are not recognized; e.g. @string should be typed as @String or you can enclose such strucutres in parentheses: @(string.Join(“ ,”, list)).

Modules compiled for version MVC 3 may work, but markup errors described above are possible as well as errors of using code, which is not supported in MVC 4.