在 asp.net webform 应用程序中选择启用 ajax 的 WCF 服务时有什么优点和缺点? [英] What are the pros and cons when choosing ajax enabled WCF service in an asp.net webform application?

查看:18
本文介绍了在 asp.net webform 应用程序中选择启用 ajax 的 WCF 服务时有什么优点和缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在示例 asp.net webform 应用程序中试验了我的第一个 ajax 启用 WCF 服务...如果我的 web 应用程序中有 10-15 个页面,其中涉及add,edit,view,delete操作,是否可以在不使用所有页面的.cs(codebehind)的情况下使它们ajax post和get...

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 webform 应用程序中选择启用 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 是更现代的技术,将是我新项目的首选.它可以为您提供以下内容:

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

作为一个缺点,我会说你需要一些时间来学习这项技术.我发现正确配置 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.

这篇关于在 asp.net webform 应用程序中选择启用 ajax 的 WCF 服务时有什么优点和缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆