📜 ⬆️ ⬇️

New version of ASP.NET MVC 3 RC2 released

image

Only a month has passed since the release of ASP.NET MVC 3 RC , but the development team is ready to present a new version of ASP.NET MVC 3 RC2. This release can be called extraordinary, since it is intended to solve compatibility issues with the recently released Visual Studio 2010 Service Pack 1 Beta .

However, besides compatibility with the fix pack for Visual Studio 2010 in MVC 3 RC2, there are a number of changes that developers need to be aware of. Below is a description of these innovations.
')
Download the ASP.NET MVC 3 RC2 package at this link .

Updated jQuery, jQuery Validation and jQuery UI versions in project templates


ASP.NET MVC 3 RC updated project templates that now contain the latest jQuery 1.4.4 JavaScript libraries, jQuery Validation 1.7, and jQuery UI 1.8.6.

New attribute AdditionalMetadataAttribute


In MVC 3 RC2, the new attribute AdditionalMetadataAttribute has been added, which allows you to add additional custom metadata for models.

image

In the future, this additional metadata will be available in the ModelMetadata.AdditionalValues ​​collection of the presentation data.

Improvements in the mechanism of scaffolding representations


Now when generating views via the “Add View” menu item, the Html.EditorFor methods are used instead of the previous explicit Html.TextBoxFor and others. This will allow you to automatically create views using the scaffolding mechanism and custom data type views.

In addition, automatically generated views now contain references to JavaScript libraries necessary for client validation.

Automatic generation of views now supports the definition of key fields (the KeyAttribute attribute) of the model, which are not required to be displayed in the view for editing.

Added helper method Html.Raw


By default, all output of model values ​​in ASP.NET MVC 3 views is escaped. To simplify the output of model field values ​​that may contain HTML markup, a new auxiliary method Html.Raw has been introduced.

For example, if we want to pass the following value to the view:

image

then the result will be a screened string:

image

In order to avoid screening, you can use the new auxiliary method:

image

We will get the desired result:

image

Developers should understand the responsibility of displaying unshielded user input values ​​on a page. For security reasons, you should always escape the values ​​that the user adds to the site.

Rename old names


In ASP.NET MVC 3 RC2, a series of class names, properties, and attributes was renamed upon user request. New names are designed to more correctly reflect the essence of the elements.

Controller.ViewModel and View (rendered) properties renamed to ViewBag

This must be the most important renaming, which affects almost all the projects created earlier on the basis of ASP.NET MVC 3. Earlier, the dynamic properties entered in MVC 3, which contained information for presentation in the controller and the presentation itself, were named differently: ViewModel and View . Now their names are unified under one name: ViewBag .

ControllerSessionStateAttribute attribute renamed to SessionStateAttribute

The ControllerSessionStateAttribute attribute introduced earlier for managing session state has now received a new short name SessionStateAttribute.

The Fields property of the RemoteAttribute attribute is renamed to AdditionalFields

The Fields property of the RemoteAttribute attribute, with which you can specify additional properties necessary for validation, was renamed to more logical AdditionalFields.

SkipRequestValidationAttribute attribute renamed to AllowHtmlAttribute

The SkipRequestValidationAttribute attribute, with which you can disable the request validation mechanism for certain parameters, was renamed AllowHtmlAttribute. The new name reflects the purpose of the attribute.

Changed Html.ValidationMessage behavior when displaying validation errors


Previously, the Html.ValidationMessage method displayed the first available validation error message. Sometimes such a message could be a message corresponding to the exception that occurred, which is not suitable for displaying an error description form.

In ASP.NET MVC 3 RC2, the Html.ValidationMessage method displays the first “helpful” error message, ignoring messages related to exceptions. If no useful messages other than the message associated with the exception are available, then messages from the exception will be used.

Fixes


In ASP.NET MVC3, several behavior corrections were presented in different parts of the framework.

@Model declaration

The @model declaration no longer leaves a blank line in the page markup.

LabelFor helper method

Fixed the bug when the LabelFor helper method generated for the attribute for the value of the name of the element, instead of the id value that is required by the standard.

RenderAction method

In previous versions of ASP.NET MVC, passing explicit parameters to the RenderAction method was ignored and the current form parameters were used instead of them during the binding of the model in action. In ASP.NET MVC 3, explicit parameters passed with the RenderAction method take precedence over form parameters.

Added FileExtensions property to the mechanism of view engines


The new FileExtensions property is intended to indicate extensions that can be processed by the presentation engines. This innovation is made in order to be able to determine which engine to use when explicitly specifying the execution of presentation files:

image

Previously, this call led to the execution of a call through Web Forms (the first registered view engine), which resulted in an exception. Now, using the new MVC 3 property can determine which engine to use for the specified file.

Conclusion


ASP.NET MVC 3 is a “polishing” release that does not contain significant changes and innovations. This version introduces one of the latest fixes and minor changes before the release of the final version of ASP.NET MVC 3. However, even minor changes in RC2 need to be known to every ASP.NET MVC developer.

Source: https://habr.com/ru/post/109894/


All Articles