As you already know ASP.NET MVC 2 hits the RC, as far as I know this is the last release before the final. There has been quite a few things that the ASP.NET MVC team has added since the v1.0. I know people says human nature is “More you get the more you want”, but the requirements that I am presenting here is not new, instead these are the enhancements of the newly added features and without it these features does not seem complete.
Yes, there has been one improvement since the beta, currently the validation script can be placed at the bottom of the page (which is recommended), but it is sill generating inline scripts after the form tag. My suggestion was to the ASP.NET MVC team was to maintain an internal queue of validation scripts and expose a method (like HtmlHelper.WirtieValidationRules() ) so that the we can call it wherever we think is appropriate. And I think the
web.config or a in a static validation setting class where we apply it globally. The reason I dislike this method is that I think, there is a very good chance that I will forget to call that method entirely or I may call it inside the
Html.BeginForm() where it does not work at all.
The next in client side validation is integration with jQuery validation libraray, As you know that the jQuery Validation Library is now a part of the Default ASP.NET MVC project, but the jQuery adapter script which is required to propagate the server side validation rules in client side still not in the default ASP.NET MVC project, The default ASP.NET MVC project only contains the MS Ajax Library adapter. I am not sure without that adapter script including the jQuery Validation script in the default ASP.NET MVC project makes any sense. I think the jQuery validation adapter script is still in the future project, which means it is not officially supported. I would expect, it will be included in the default ASP.NET MVC project when the RTM is out.
Template aka DisplayFor/EditorFor is a nice addition, but there are currently few things that I would like to discuss, the first and less important one, there is no way to create code templates like the built-in templates, as per Brad Wilson they are evaluating it for v3. The second and more important one, currently the built-in ModelMetaData (DataAnnotation) provider only cares the things that it knows, which means if I decorate my Model with some custom attributes, it is not possible to access those attributes in from the template. The only way to resolve this issue is to write a custom provider. But I think writing a provider for performing a simple task like showing a DropDownList is an overkill. The last one is DataAnnotation which is rather a feature request. One of the important attribute of DataAnnotation is
DataTypeAttribute which takes the data type as an enumeration. I think the ASP.NET MVC framework can make more intelligent decisions when this attribute is applied currently it only uses it for format string . For example, when I mark a property of a Model as Email or Url it should automatically add the corresponding validators in the ModelMetaData. There are also few small issues that I think is the limitation of the DataAnnotation itself rather than the ASP.NET MVC. For example, both Html and MultilineText cannot be applied to the same model property, StringLength attribute only support max length but no min length, still some of the important validators are missing such as data type checking, comparer, range for other than numeric etc which makes it as not as powerful as Webforms validation.
I think this is the most weakest thing in the MVC2. Currently it is implemented in a way that you either get all or none. My initial assumption was it supports pluggable areas out of the box. But there is no built-in support for enabling/disabling/loading/unloading Areas. The last feedback I got from the MVC team is, they have this as internal work item and they are not sure when it will be added in the core. For the time being, my suggestion would be to change the
AreaRegistration, so that it can at least support individual area registration rather than bulk.
I will be looking forward to the ASP.NET MVC Team to include the above enhancements in the RTM.