Angular 2 http.get to C#MVC with parameters

Angular 2 http.get to C#MVC with parameters,c#,angularjs,asp.net-mvc,C#,Angularjs,Asp.net Mvc,正在尝试放置带有参数的http.get: Angular2服务: getAvailability(customerId) { var Customer = this.Customer.getValue(); var data = ({ 'customerId': Customer.Id, 'eventId': eventId}); console.log("service_data_body", data); this.http.get("GetAvail

正在尝试放置带有参数的http.get:

Angular2服务:

getAvailability(customerId) {
    var Customer = this.Customer.getValue();
    var data = ({ 'customerId': Customer.Id, 'eventId': eventId});
      console.log("service_data_body", data);  
    this.http.get("GetAvailability", data)
        .map(res => res.json()).subscribe((x) => {
            console.log("callback succes");
        });

}
MVC控制器:

public ActionResult GetAvailability(int? customerId, int? eventId)
{
    var k = customerId; 
    var l = eventId;
    .......
 //some other implementation code....
}
我在构建时没有收到任何错误,但在运行时收到了任何错误。在调试时,控制台日志会给我一些值,但在放置断点时,似乎没有发送到C#(var k和var l为null)。因此,js服务没有以适当的方式传递变量


欢迎任何帮助。

这是一个简单的解决方案。为什么看起来你在试图在体内发送数据?尝试将数据包含为url参数

getAvailability(customerId) {
    var Customer = this.Customer.getValue();
    var query = "?customerId=" + Customer.Id + "&eventId=" + eventId;
    console.log("service_data_query", query);  
    this.http.get("GetAvailability" + query)
        .map(res => res.json()).subscribe((x) => {
            console.log("callback succes");
        });

}

这是一个好机会。为什么看起来你在试图在体内发送数据?尝试将数据作为url参数包含进来。好吧,我正在传递我的“条件”,以便返回一个对象。因此,您的解决方案对我来说非常有效(尽管我修改了它,以加密url中的值)。谢谢你抽出时间!