asp.net mvc 2 beta 出来了,增加Area可视化操作特性等。

New Features

This section describes features that have been introduced in the ASP.NET MVC 2 Beta release.

New RenderAction Method

Html.RenderAction (and its counterpart Html.Action) is an HTML helper method that calls into an action method from within a view and renders the output of the action method in place. Html.RenderAction writes directly to the response, whereas Html.Action returns a string with the output. RenderAction works only with actions that render views.

Strongly Typed UI Helpers

ASP.NET MVC 2 includes new expression-based versions of existing HTML helper methods. The new helpers include the following:

·         ValidationMessageFor

·         TextAreaFor

·         TextBoxFor

·         HiddenFor

·         DropDownListFor

TempDataDictionary Improvements

The behavior of the TempDataDictionary class has been changed slightly to address scenarios where temp data was either removed prematurely or persisted longer than necessary. For example, in cases where temp data was read in the same request in which it was set, the temp data was persisting for the next request even though the intent was to remove it. In other cases, temp data was not persisted across multiple consecutive redirects.

To address these scenarios, the TempDataDictionary class was changed so that all the keys survive indefinitely until the key is read from the TempDataDictionary object. The Keep method was added to TempDataDictionary to let you indicate that the value should not be removed after reading. The RedirectToActionResult is an example where the Keep method is called in order to retain all the keys for the next request.

Client Validation Library

MicrosoftMvcAjax.js now includes a client-side validation library that is used to provide client validation for models in ASP.NET MVC. To enable client validation, include the following two scripts in your view.

·         MicrosoftAjax.js

·         MicrosoftMvcAjax.js

The following example shows a view with client validation enabled.

<script type="text/javascript" src="MicrosoftAjax.js"></script>

<script type="text/javascript" src="MicrosoftMvcAjax.js"></script>

 

<% Html.EnableClientValidation(); %>

<% using(Html.BeginForm()) { %

 //...

<% } %>

“Add Area” Dialog Box

ASP.NET MVC 2 Beta includes a new Add Area context menu item when you right-click either the root project node or the Areas folder (if one exists). If a root Areas folder does not already exist, the command creates one, and it then creates the files and folders for the area that you specify.

Calling Action Methods Asynchronously

The AsyncController class is a base class for controllers that enables action methods to be called asynchronously. This lets an action method call external services such as a Web service without blocking the current thread. For more information, see Using an Asynchronous Controller in ASP.NET MVC In the ASP.NET MVC 2 documentation.

Blank Project Template

In response to customer feedback, an empty ASP.NET MVC project template is now included with ASP.NET MVC 2 Beta. This empty project template contains a minimal set of files used to build a new ASP.NET MVC project.

Multiple Model Validator Providers

ASP.NET MVC 2 Beta lets you register multiple validation providers. The following example shows how to register multiple providers.

protected void Application_Start() {

    ModelValidatorProviders.Providers.Add(new MyXmlModelValidatorProvider());

    ModelValidatorProviders.Providers.Add(new MyDbModelValidatorProvider());

    //...

}

Multiple Value Provider Registration

In ASP.NET MVC 2 Beta, the single value provider that was available in ASP.NET MVC 1.0 has been split into multiple value providers, one for each source of request data. The new value providers include the following:

·         FormValueProvider

·         RouteDataValueProvider

·         QueryStringValueProvider

·         HttpFileCollectionValueProvider

These value providers are registered by default. You can register additional value providers that pull data from other sources. The following example shows how to register additional value providers in the in Global.asax file.

protected void Application_Start() {

    ValueProviders.Providers.Add(new JsonValueProvider());

    //...

}

Other Improvements

The following additional changes have been made to existing types and members for ASP.NET MVC 2 Beta.

·         The build task for multi-project areas has been removed and placed in the ASP.NET MVC Futures project.

·         A new GetDisplayName method was added to the ModelMetadata class.

·         A new IsComplexType property was added to the ModelMetadata class.

·         Default object templates display only top-level properties of a model and do not attempt to recursively display properties of the properties of the model.

·         ViewDataDictionary<T> now allows value types for the Model property.

·         A new HideSurroundingHtml property was added to the ModelMetadata class. This is used to indicate that the HTML “chrome” surrounding a field in a template should not be displayed.

·         Templated helpers now support byte[] and System.Linq.Binary properties on the model. When the HiddenInput UI hint attribute is applied to properties of these types, the editor template will Base-64-encode the value of these properties in a hidden input element.

·         A new AdditionalValues dictionary property was added to the ModelMetadata class.

·         A new RouteLink method overload was added that requires only two parameters, link text and the route name.

·         A new protected virtual CreateTempDataProvider method was added to the Controller class. This allows you to supply a custom derived TempDataProvider object by overriding that method.

·         When the model is binding to a collection, the DefaultModelBinder object no longer requires collection indexes to be an unbroken ascending sequence of positive integers.

·         A new Ajax.Escape method was added that lets you escape JavaScript strings.

·         The default templates for the Decimal type now format values to two decimal places.

·         GenerateUrl is now a public method of UrlHelper.

·         The AccountController class in the default template was updated to make use of the template helpers and data annotations.

·         Modified the default T4 templates for the Add View dialog to emit expression based helpers. Also removed the validation summary.
下载地址:asp.net mvc beta下载

posted @ 2009-11-18 09:37  yuhe7919  阅读(637)  评论(0编辑  收藏  举报
我的应用测试