Call external site webmethod using jsonp?

淺唱寂寞╮ 提交于 2019-12-04 21:07:35

JSONP is not magic.

You can only use JSONP to read data from a URL that returns JSONP script.
ASP.Net WebMethods do not support JSONP.

I guess you're missing the proper attributes, as following (in an .asmx definition):

    [WebMethod(EnableSession = true)] // optional, but usually forgotten
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public bool MyMethod(int id)
    {
        return true;
    }

plus, you need to have Content-rewrite module for handling the leading callback parameter as well:

http://www.codeproject.com/Articles/43038/Accessing-Remote-ASP-NET-Web-Services-Using-JSONP

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!