Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

Are MicrosoftAjax.js, MicrosoftMvcAjax.js and MicrosoftMvcValidation.js obsolete as of ASP.NET MVC 3? I haven't been able to find much info on this on the web, but from what I've read it implies that these files were used in ASP.NET MVC 1-2, and were replaced by jquery.validate.min.js, jquery.unobtrusive-ajax.min.js and jquery.validate.unobtrusive.min.js. Is that correct? Do I still need the Microsoft files?

share|improve this question
up vote 116 down vote accepted

Yes, all Microsoft* helpers are obsolete in ASP.NET MVC 3. For me they have always been obsolete but now at least Microsoft made this official and replaced them with jQuery.

2 new functionalities have been introduced

<appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>

The first is UnobtrusiveJavaScriptEnabled. This means that if you enable this functionality in your web.config (its enabled by default when you create a new ASP.NET MVC 3 application), all the Ajax.* helpers such as Ajax.BeginForm and Ajax.ActionLink will emit HTML5 data-* attributes on their respective DOM elements instead of mixing javascript with markup. Then you should include the jquery.unobtrusive-ajax.js script to your page which will parse those attributes and use jQuery to unobtrusively AJAXify them.

The second is ClientValidationEnabled which is also enabled by default. The same way unobtrusive javascript works, when you enable this setting all helpers that generate input fields will emit HTML5 data-* attributes on them. Then you include jquery.validate.js and jquery.validate.unobtrusive.js scripts to make them work, such as in your _Layout.cshtml. They must appear in this order, and they must be after jquery is loaded:

<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

So in ASp.NET MVC 3 you can forget about all Microsoft* scripts. Remove them from your site. Delete those files.

share|improve this answer
5  
Absolutely perfect answer, this is EXACTLY what I was looking for. Upvoted and accepted. ;) – Jake Petroules Jan 9 '12 at 8:06
    
Great answer, thanks for help – J.W. Jun 8 '12 at 15:52
    
Thank you darin. Note : it seems latest version jquery-1.10.2.min.js doesn't work, using jquery-1.7.1.min.js worked for me. – stom May 13 '15 at 11:33

You only need the MicrosoftAjax functionality if you are using the libraries. Microsoft AJAX does offer some functionality not found in the provided JQuery libraries (although could be replicated with plug-ins). If you are not using Microsoft AJAX within your application you can delete all reference to these scripts.

share|improve this answer
    
What actually does use them, though? – Jake Petroules Jan 9 '12 at 0:30
    
It's an alternate JavaScript library - similar to JQuery UI, details are here: asp.net/ajaxlibrary/act_tutorials.ashx. I believe Microsoft have slowly moved away from contributing to MS AJAX and instead contribute to JQuery instead (such as the templating library). – LewisBenge Jan 9 '12 at 0:38
    
Put is this way - would I know whether I were using it? – Jake Petroules Jan 9 '12 at 1:05
    
Yes - you would be calling methods specific to that framework, and would need to reference the JS in your HTML. – LewisBenge Jan 9 '12 at 1:05
    
Here, channel9.msdn.com/Blogs/matthijs/ASPNET-AJAX-40-by-Fritz-Oni‌​on, announced that Microsoft is moving to jQuery extensions. – Roman Feb 19 '13 at 18:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.