Looking at the new ASP.NET MVC framework it comes with javascript files for both ASP.NET AJAX and JQuery.
查看新的ASP.NET MVC框架,它附带了ASP.NET AJAX和JQuery的javascript文件。
Can someone explain what ASP.NET AJAX gives me that JQuery doesn't?
有人可以解释ASP.NET AJAX给我的JQuery没有的东西吗?
Do I need to use both and can you give me examples where I would/would not need to use both?
我是否需要同时使用这两种方法,你能举例说明我/不需要同时使用这两种方法吗?
I've used JQuery on plenty of non ASP.NET projects (PHP and prototype sites) and have used JQuery Ajax quite happily, but I'm unsure what's best to use for ASP.NET.
我在很多非ASP.NET项目(PHP和原型站点)上使用过JQuery,并且非常愉快地使用了JQuery Ajax,但我不确定什么是最适合ASP.NET的。
Thanks for your time Sniffer
谢谢你的时间嗅探器
4 个解决方案
#1
I've recently been writing ASP.NET MVC pages without Microsoft AJAX. Conclusions? You need to do a bit more wiring to get it working, especially with server side communications (tip: use JSON.NET, not the built-in stuff), but it is vastly shorter and more readable. I won't be using Microsoft AJAX again.
我最近一直在编写没有Microsoft AJAX的ASP.NET MVC页面。结论是什么?你需要做一些更多的连接才能使它工作,尤其是服务器端通信(提示:使用JSON.NET,而不是内置的东西),但它更短,更易读。我不会再使用Microsoft AJAX了。
ASP.NET AJAX gives you:
ASP.NET AJAX为您提供:
- a bunch of ASP.NET controls that provide AJAX functionality. These are painful to use and even more painful to write. jQuery extensions are much cleaner, but have a steeper learning curve for an ASP.NET programmer.
- The ability to auto-generate classes which perform AJAX calls. This is really cool, but you can live without it.
- A namespace and event model, which you won't need if you program jQuery style.
- The ability to do partial renders of pages. Only useful if you're not using MVC, and rarely advisable even then.
一堆提供AJAX功能的ASP.NET控件。这些都是痛苦的使用,写作更痛苦。 jQuery扩展更清晰,但对于ASP.NET程序员来说学习曲线更陡峭。
能够自动生成执行AJAX调用的类。这真的很酷,但你可以没有它。
命名空间和事件模型,如果您编写jQuery样式,则不需要它。
能够对页面进行部分渲染。仅在您不使用MVC时才有用,即使在那时也很少可取。
Conclusion: Use jQuery, remove Microsoft AJAX.
结论:使用jQuery,删除Microsoft AJAX。
#2
A difference of opinion then(!), but thanks for the feedback.
然后是(!)的意见分歧,但感谢您的反馈。
For info, I found this thread which answers my questions a little more clearly.
有关信息,我发现这个帖子可以更清楚地回答我的问题。
jQuery vs MicrosoftAjax in ASP.NET MVC
ASP.NET MVC中的jQuery与MicrosoftAjax
I think I'll be going with just jQuery for the comfort factor, easier to read code, small file sizes, etc. and see how I go.
我想我将只使用jQuery来获得舒适因素,更容易阅读代码,小文件大小等等,看看我如何去。
Thanks again Sniffer
再次感谢Sniffer
#3
I use JQuery for retrieving Json data and Microsoft AJAX for posting forms. You could do both with JQuery, but I don't really like serializing the form myself. At the end of the day Microsoft AJAX is pretty decent - if you need to write less JavaScript code yourself that's less code that you need to maintain.
我使用JQuery检索Json数据,使用Microsoft AJAX发布表单。你可以用JQuery做两件事,但我真的不喜欢自己序列化表单。在一天结束时,Microsoft AJAX非常不错 - 如果您需要自己编写更少的JavaScript代码,那么您需要维护的代码更少。
So to answer your question - Microsoft AJAX doesn't really add anything that JQuery doesn't have. It simply allows you to use helpers which get translated to pretty much the same JavaScript code that you can write with JQuery. Like I said - less JavaScript code you write yourself is less code that you need to maintain.
所以回答你的问题 - 微软AJAX并没有真正添加JQuery没有的东西。它只是允许您使用帮助程序,这些帮助程序可以转换为与您使用JQuery编写的几乎相同的JavaScript代码。就像我说的那样 - 你自己编写的JavaScript代码越少,你需要维护的代码越少。
There are no real examples of where you should or shouldn't use the one or the other - it comes down to personal preference IMO.
没有真正的例子说明你应该或不应该使用这一个 - 它归结为个人偏好IMO。
#4
Asp.Net AJAX was designed for Asp.Net WebForms, not MVC. It was designed to do many things that jQuery already did. Before MS agreed that bundling jQuery with Asp.Net MVC was a good idea, Asp.Net AJAX was all they had.
Asp.Net AJAX是为Asp.Net WebForms设计的,而不是MVC。它的目的是做jQuery已经做过的很多事情。在MS同意将jQuery与Asp.Net MVC捆绑在一起之前是一个好主意之前,Asp.Net AJAX就是他们所拥有的。
Asp.Net AJAX tries to replicate part of the server side environment in the client's browser - you can see this with the MS-like JS namespaces. It was designed for WebForms when everything was based on the post-back model.
Asp.Net AJAX尝试在客户端的浏览器中复制部分服务器端环境 - 您可以使用类似MS的JS命名空间来查看它。它是为WebForms设计的,当时所有内容都基于后置模型。
The MVC paradigm tries to decouple and simplify aspects of web development by being honest with how HTTP works. Asp.Net AJAX does not really fit in this space because of how tightly it was designed with WebForms. In the same way that you can hack get WebForms controls to work in MVC (because it's still built on the ASP.NET core) you can also get Asp.Net AJAX to work in MVC - but the real point is this:
MVC范例试图通过诚实地了解HTTP的工作方式来分离和简化Web开发的各个方面。 Asp.Net AJAX并不真正适合这个领域,因为它与WebForms的设计有多紧密。以同样的方式你可以破解让WebForms控件在MVC中工作(因为它仍然构建在ASP.NET核心上)你也可以让Asp.Net AJAX在MVC中工作 - 但真正的重点在于:
jQuery and MVC (by design and definition) were meant for each other.
jQuery和MVC(按设计和定义)是相互意味着的。
(hope my answer is not too subjective :D)
(希望我的答案不太主观:D)
#1
I've recently been writing ASP.NET MVC pages without Microsoft AJAX. Conclusions? You need to do a bit more wiring to get it working, especially with server side communications (tip: use JSON.NET, not the built-in stuff), but it is vastly shorter and more readable. I won't be using Microsoft AJAX again.
我最近一直在编写没有Microsoft AJAX的ASP.NET MVC页面。结论是什么?你需要做一些更多的连接才能使它工作,尤其是服务器端通信(提示:使用JSON.NET,而不是内置的东西),但它更短,更易读。我不会再使用Microsoft AJAX了。
ASP.NET AJAX gives you:
ASP.NET AJAX为您提供:
- a bunch of ASP.NET controls that provide AJAX functionality. These are painful to use and even more painful to write. jQuery extensions are much cleaner, but have a steeper learning curve for an ASP.NET programmer.
- The ability to auto-generate classes which perform AJAX calls. This is really cool, but you can live without it.
- A namespace and event model, which you won't need if you program jQuery style.
- The ability to do partial renders of pages. Only useful if you're not using MVC, and rarely advisable even then.
一堆提供AJAX功能的ASP.NET控件。这些都是痛苦的使用,写作更痛苦。 jQuery扩展更清晰,但对于ASP.NET程序员来说学习曲线更陡峭。
能够自动生成执行AJAX调用的类。这真的很酷,但你可以没有它。
命名空间和事件模型,如果您编写jQuery样式,则不需要它。
能够对页面进行部分渲染。仅在您不使用MVC时才有用,即使在那时也很少可取。
Conclusion: Use jQuery, remove Microsoft AJAX.
结论:使用jQuery,删除Microsoft AJAX。
#2
A difference of opinion then(!), but thanks for the feedback.
然后是(!)的意见分歧,但感谢您的反馈。
For info, I found this thread which answers my questions a little more clearly.
有关信息,我发现这个帖子可以更清楚地回答我的问题。
jQuery vs MicrosoftAjax in ASP.NET MVC
ASP.NET MVC中的jQuery与MicrosoftAjax
I think I'll be going with just jQuery for the comfort factor, easier to read code, small file sizes, etc. and see how I go.
我想我将只使用jQuery来获得舒适因素,更容易阅读代码,小文件大小等等,看看我如何去。
Thanks again Sniffer
再次感谢Sniffer
#3
I use JQuery for retrieving Json data and Microsoft AJAX for posting forms. You could do both with JQuery, but I don't really like serializing the form myself. At the end of the day Microsoft AJAX is pretty decent - if you need to write less JavaScript code yourself that's less code that you need to maintain.
我使用JQuery检索Json数据,使用Microsoft AJAX发布表单。你可以用JQuery做两件事,但我真的不喜欢自己序列化表单。在一天结束时,Microsoft AJAX非常不错 - 如果您需要自己编写更少的JavaScript代码,那么您需要维护的代码更少。
So to answer your question - Microsoft AJAX doesn't really add anything that JQuery doesn't have. It simply allows you to use helpers which get translated to pretty much the same JavaScript code that you can write with JQuery. Like I said - less JavaScript code you write yourself is less code that you need to maintain.
所以回答你的问题 - 微软AJAX并没有真正添加JQuery没有的东西。它只是允许您使用帮助程序,这些帮助程序可以转换为与您使用JQuery编写的几乎相同的JavaScript代码。就像我说的那样 - 你自己编写的JavaScript代码越少,你需要维护的代码越少。
There are no real examples of where you should or shouldn't use the one or the other - it comes down to personal preference IMO.
没有真正的例子说明你应该或不应该使用这一个 - 它归结为个人偏好IMO。
#4
Asp.Net AJAX was designed for Asp.Net WebForms, not MVC. It was designed to do many things that jQuery already did. Before MS agreed that bundling jQuery with Asp.Net MVC was a good idea, Asp.Net AJAX was all they had.
Asp.Net AJAX是为Asp.Net WebForms设计的,而不是MVC。它的目的是做jQuery已经做过的很多事情。在MS同意将jQuery与Asp.Net MVC捆绑在一起之前是一个好主意之前,Asp.Net AJAX就是他们所拥有的。
Asp.Net AJAX tries to replicate part of the server side environment in the client's browser - you can see this with the MS-like JS namespaces. It was designed for WebForms when everything was based on the post-back model.
Asp.Net AJAX尝试在客户端的浏览器中复制部分服务器端环境 - 您可以使用类似MS的JS命名空间来查看它。它是为WebForms设计的,当时所有内容都基于后置模型。
The MVC paradigm tries to decouple and simplify aspects of web development by being honest with how HTTP works. Asp.Net AJAX does not really fit in this space because of how tightly it was designed with WebForms. In the same way that you can hack get WebForms controls to work in MVC (because it's still built on the ASP.NET core) you can also get Asp.Net AJAX to work in MVC - but the real point is this:
MVC范例试图通过诚实地了解HTTP的工作方式来分离和简化Web开发的各个方面。 Asp.Net AJAX并不真正适合这个领域,因为它与WebForms的设计有多紧密。以同样的方式你可以破解让WebForms控件在MVC中工作(因为它仍然构建在ASP.NET核心上)你也可以让Asp.Net AJAX在MVC中工作 - 但真正的重点在于:
jQuery and MVC (by design and definition) were meant for each other.
jQuery和MVC(按设计和定义)是相互意味着的。
(hope my answer is not too subjective :D)
(希望我的答案不太主观:D)