当一个asp.net web窗体应用程序选择支持AJAX的WCF服务有哪些优点和缺点?窗体、应用程序、缺点、优点

2023-09-10 16:31:59 作者:余温散尽

我刚刚尝试我的第一个 AJAX的WCF服务样品 asp.net web窗体应用...如果我有10-15页,在我的web应用,涉及添加,编辑,查看和删除操作,是有可能使它们阿贾克斯后,获得而不使用的.cs(codebehind)的所有网页...

I have just experimented my first ajax enabled WCF service in a sample asp.net webform application... If i have 10-15 pages in my webapplication which involves add,edit,view and delete operations, is it possible to make them ajax post and get without using .cs(codebehind) of all pages...

有哪些优点和缺点,当在一个asp.net web窗体应用程序选择支持AJAX的WCF服务?

What are the pros and cons when choosing ajax enabled WCF service in an asp.net webform application?

推荐答案

首先,如果你想实现服务器端的jQuery的Ajax调用,您可与ASMX或WCF服务做到这一点。你可以找到这两者之间一个简短的对比这里。 WCF是更现代的技术,将是我的preferred选择新项目。它可以为您提供以下内容:

At first, if you want to implement the server side of jQuery Ajax calls, you can do this with either ASMX or WCF services. You can find a short comparison between these two here. WCF is more modern technology and will be my preferred choice for new projects. It can provide you with the following:

帮助你对编程接口 这会为你序列化/反序列化对象的JSON。无需JSON库 提供,您可以使用(通过ScriptManager的)客户端的方法。这也很容易使用jQuery,如果你preFER

作为一个缺点,我会说,它会带你一些时间来学习这项技术。我发现web.config中的正确配置是有点棘手。

As an disadvantage I would say that it will take you some time to learn the technology. I found that proper configuration of web.config was a little tricky.

我通常有一个服务于所有Ajax请求单个SVC服务。只要你想在一个单一的服务,您可以实现尽可能多的方法。该服务被称为从不同的网页。

I usually have a single svc service that serves all Ajax requests. You can implement as many methods as you want in a single service. The services are called from different pages.