帮助我理解网络方法?
我在标有 webmethod 和 scriptmethod 标签的页面上有一个方法。
该方法将对象集合作为 JSON 数据返回到 jquery 函数,没有任何麻烦,而且不需要我手动序列化它。
我现在尝试使用 HTTPHandler 重新创建相同的方法,并且想知道为什么我现在必须手动序列化数据。
是什么让网络方法与众不同?
I have a method on a page marked with the webmethod and scriptmethod tags..
The method returns a collection of objects to a jquery function as JSON data with no hassles and without me having to manually serialize it.
I am now trying to recreate that same method using a HTTPHandler and was wondering why i have to now manually serialize the data.
What makes the webmethod different?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为 HTTP 处理程序(某种意义上)位于 ASP WebForms 堆栈之上,所以您完全负责该处理程序的工作和输出。
您可以利用(几乎)任何您能在 .NET 框架中获得的东西,但可以肯定的是,HTTPHandler 比 ASP.NET 提供的现成解决方案需要更多工作。
请参阅 http://msdn.microsoft。 com/en-us/library/ms227675(VS.85).aspx
Because an HTTP handler (kind of) sits above the ASP WebForms Stack, you are totally responsible for the workings and output of the handler.
You can utilise (almost) anything you can get your hands on within the .NET framework, but for sure, an HTTPHandler will be more work than an off-the-shelf solution provided by ASP.NET.
See http://msdn.microsoft.com/en-us/library/ms227675(VS.85).aspx
Web 方法为您提供了 C# 类和 Js 文件之间的连接。如今,使用 Json 是以智能格式获取 js 函数或 js 文件中任何位置的返回消息的最佳方法。
问候
Web method provides you a connection between your c# class and Js file. Nowadays Using Json is a best way to get the return message in a smart format for a js function or anywhere in js file.
Regards
对于较少的工作:
将您的方法移至 ASMX(Web 服务):
您将受益于 ScriptService 提供的内置序列化:
在客户端:
For lesser work:
Move your method to an ASMX (Web Service):
You will benefit the built-in serialization provided by the ScriptService:
On the client side: