JSONP w回调的ASP.NET 3.5 WebService示例 [英] ASP.NET 3.5 WebService example for JSONP w callback

查看:85
本文介绍了JSONP w回调的ASP.NET 3.5 WebService示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能指出一些示例代码,这些代码演示如何设置跨域Web服务,该服务将在.asmx/ASP.NET 3.5页面中返回JSON?似乎无法找到全面的例子.

我想避免使用MVC或WCF-尤其是既然ASP.NET Web API是最新的也是最好的,但是对于本机支持(我认为)并没有清除.我见过人们说可以将自定义格式器添加到Web API格式器集合等中,但是该代码仅适用于CodePlex版本,并且构建过程不断变化,更好地等待RTM.

我已经在asmx页面上建立了成功的Web服务,并使用jQuery来获取JSON,但现在需要提供一个API,以便其他域上的外部合作伙伴可以访问该服务并获取JSON格式的数据.我的薄弱理解是需要回调以及添加HttpModule来设置content-type的必要性?

Can anyone point me to some example code that shows how to setup a cross domain webservice that will return JSON in a .asmx / ASP.NET 3.5 page? Cant seem to find a comprehensive examples.

I want to avoid MVC or WCF - especially now that the ASP.NET Web API is the latest and greatest but the smoke hasn''t cleared w respect to native support (I think). Ive seen folks saying that a custom formatter can be added to the Web API formatter collection etc but that the code only works with the CodePlex version and builds are in flux and better to wait for RTM.

Ive set up successful web services in asmx pages and used jQuery to get JSON but now need to deliver an API so external partners on other domains can hit the service and get JSON formatted data back. My weak understanding is that callbacks are required along with it being neccessary to add an HttpModule to set the content-type ?

Cheers & thanx in advance !

推荐答案

使用WCF会很容易:
http://www.west-wind.com/weblog/posts/2007/Oct/04/WCF-and-JSON-Services [
It would be easy with WCF:
http://www.west-wind.com/weblog/posts/2007/Oct/04/WCF-and-JSON-Services[^] even though you say you want to avoid WCF.


这篇关于JSONP w回调的ASP.NET 3.5 WebService示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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