ASP.NET MVC V2 Preview 1 released - Debriefing

    imageThe other day MVC 2 Preview 1 became available to the general public. This release of the framework contains very significant innovations, which I will try to briefly describe in this article. First of all, it should be noted that, as in the case of the first version, the status of “Preview 1” means a technical demonstration of the changes and new functionality. It is expected that the interested developer community will test and evaluate this release and based on feedback in the MVC Framework, changes will be made for the release of Preview 2, and so on, until the final release of the second version. In other words, this release is not intended for use, as they say, “in production”. It is very likely that future releases may contain more or less significant changes, due to which,

    What's new?


    So what is new in this release? I bring to your attention a more or less complete list of changes and innovations in MVC Framework 2 compared to the first version:
    • Strongly Typed UI Helpers - allow you to define in the markup the presentation of certain data through the type received from the lambda expression. This allows, firstly, to use intellisense, and secondly, reduces the number of possible errors at the compilation stage;
    • Template helpers (Templated Helpers) - allow you to map a piece of markup to a certain complex type and then render a markup with a single line of code for markup to display information, for example, markup for editing this information. Used in conjunction with a strongly typed helper mechanism;
    • Areas (Areas) - the mechanism of regions allows you to select (or vice versa merge from small projects into one) a functional of different nature. For example, in one project you can define areas for a forum, blog, news site, image gallery and other parts. In other words, areas are an add-on over controllers that allows you to group them;
    • Support for data annotations. MVC Framework 2 received support for the .net component model engine, which is implemented in the System.ComponentModel.DataAnnotations namespace . This allows you to create a meta-information definition for types and properties, which is later used in different places, for example, for validating data received from a client on the server side;
    • The new [HttpPost] attribute allows you to specify the same as [AcceptVerbs (HttpVerbs.Post)], only to make it shorter;
    • Component model support extends to the support of the DefaultValue attribute, which allows you to specify a default value for action parameters. In C # 4.0, you can use the default parameter engine built into the language instead;
    • Binding to binary data allows you to transparently match binary data represented by base64 strings with action parameters like byte [].

    What changed?


    In addition to the innovations in the MVC Framework 2, some of the old functions also changed:
    • a new protected CreateActionInvoker method of the Controller class, which is called by the ActionInvoker property to lazily create an ActionInvoker, if it has not already been created;
    • new protected virtual method OnAuthorizationFailed in the AuthorizationFilter class , which allows filters inherited from AuthorizationFilter to handle the event when authorization has not been performed;
    • new Add (string key, object value) method for the ValueProviderDictionary class , which allows using the simplified dictionary initialization syntax for ValueProviderDictionary;
    • new get_object method for the Sys.Mvc.AjaxContext class . This javascript method is like the old get_data method, but differs from it in that it returns a JSON object if it was returned by the client;
    • the new ActionDescriptor property in the AuthorizationContext class contains information about the action;
    • Removed RequestContext property in DefaultControllerFactory . Instead , RequestContext is passed to the GetControllerInstance and GetControllerType methods . This change may “break” previous user implementations of controller factories;
    • the area value is now reserved for use in route pattern settings.

    What is fixed?


    In addition to innovations and changes, some errors and shortcomings were fixed. Their translation was somewhat difficult, since I did not encounter any of the bugs. Therefore, if you find a mistake in the translation, then let me know:
    • fixed compilation error for view, which contained Unicode characters in the title;
    • HTML helpers threw a NullReferenceException when adding a ModelError without setting a value. Now an exception is not raised;
    • previously, the SessionStateTempDataProvider class operation stopped with an error if the session state mechanism was not enabled. Now the provider throws an exception only if an attempt is made to save data to the session state object when this object is prohibited;
    • AJAX helpers can now submit submit-button or submit-image data as part of the request when sending data from the form. In order for this to work in old projects, after updating the project itself, update the MicrosoftMvcAjax.js library;
    • Previously, an error occurred while compiling views with a view type of ViewMasterPagethat did not contain a single block <% = ...%>. This has been fixed.

    What will happen next?


    The MVC Roadmap official page lists the following areas in which the MVC Framework will evolve:
    • client side validation;
    • Strongly typed helpers for creating form fields
    • strongly typed helpers for creating hyperlinks;
    • asynchronous actions;
    • expansion of the functional areas.

    In addition, if you collect ScottGu's answers in the comments, you can make up a small list of what the development team is working on:
    • strongly-typed action generators;
    • caching the results of lambda expressions to optimize the performance of views and UI helpers;
    • RenderAction will be included in the MVC Framework closer to release;
    • MVC Framework V2 will not appear for Visual Studio 2010 beta1, but will be enabled by default in beta2;
    • and finally, when asked about the classic asp.net and whether there will be anything new for him, Scott replied: “Absolutely! I'll be doing a big blog post series soon that talks about the improvements to WebForms coming with ASP.NET 4.0. There are a bunch of great new non-MVC features coming as part of that release. ”. Waiting for.

    useful links



    I think the links for the first time will be enough. If possible, I will try to write several articles on the topic.

    Conclusion


    MVC Framework is developing rapidly. The new functionality that appeared in V2 Preview 1 is very interesting and is sure to find wide application in practice. Do not forget only that, as before, preview versions are not recommended for use in production. If you still run the risk of incorporating some new features into a running application, be prepared for the fact that future releases of MVC V2 may require rewriting some of the code.
    While the developers are waiting for us and you feedback and reports on bugs found. Enjoy your programming!

    Progg it

    Also popular now: