【发布时间】:2014-01-25 12:04:18
【问题描述】:
我正在使用backbone.js 发送一个GET 请求并将模型作为参数传递。
我的模型如下:-
class Vehicle
{
public int Id
public string Name
}
class Car
{
public string Type
public Vehicle Vehicle
}
现在,我的控制器是:-
[HttpGet]
public ActionResult GetClasBDetails(Car carModel){
// Something goes here
}
当我这样做时:-
this.model.fetch({
data: $.param({//I have tried removing $.param also
Vehicle: {
Id: '1',// Also tried '1' and 1(as numeric)
Name:'ford mustang'
},
Type: "Ford"
}),
success: function (data) {
}
});
当我运行上面的代码时,Type 属性被映射并且我得到了正确的值,但不是Vehicle。有什么想法吗?
我必须在 HttpGet 请求中发送一个对象,因为有些复杂,请忽略它。
编辑:-
网址看起来像
http://localhost/Home/GetClasBDetails?Vehicle%Id%5D=10&Vehicle%Name%5D=Bed+10&Type=1
【问题讨论】:
-
如果查看发送的get请求,它是什么样的?
标签: c# asp.net asp.net-mvc backbone.js query-string