【发布时间】:2012-09-02 20:56:09
【问题描述】:
我正在尝试将 POST 数据发送到我的另一个域上的 Asp.Net Web API。我需要支持 IE9/8,所以CORS 不会删减它。当我这样打电话时:
$.ajax({
type: "GET",
url: "http://www.myotherdomain.com/account",
data: "{firstName:'John', lastName:'Smith'}",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function(msg) {
console.log(msg);
},
error: function(x, e) {
console.log(x);
}
});
它发出GET 请求:
http://www.myotherdomain.com/account?
callback=jQuery18008523724081460387_1347223856707&
{firstName:'John',%20lastName:'Smith'}&
_=1347223856725
我已经实现了this JSONP Formatter for ASP.NET Web API,并且我的服务器以格式正确的 JSONP 响应进行响应。我不明白如何注册路由以使用帐户对象。
config.Routes.MapHttpRoute(
name: "Account",
routeTemplate: "account",
defaults: new { controller = "account", account = RouteParameter.Optional }
);
如何从没有名称的查询字符串参数中反序列化对象?
【问题讨论】:
标签: asp.net-mvc iis asp.net-web-api jsonp