繁体   English   中英

对.NET Server的Angular JS http请求

[英]Angular JS http Request to .NET Server

我正在尝试使用Angular JS向.NET服务器发出post请求

我能够得到响应,但是服务器没有看到我的请求数据。

客户:

var header = {"Content-Type":"multipart/form-data"};

var data = {name:"bill", email:"bill@email.com", phone:"1234567890" };

$http.post("//dot.net/resource", data, header).then(function(res){

    console.log(res.data);

},function(err){ console.log(err); });

服务器:

if(HttpContext.Current.Request.HttpMethod.ToString().ToLower() == "post") {

    Response.Write("hello request");      // I see this in the response
    Response.Write(Request.Form["name"]); // nothing : (
}

我对.NET不太熟悉。 Request.Form基本上像php中的$_POST一样吗?

如何使用$http将一些变量传递给服务器?

尝试使用JSON.stringify(data)将数据作为字符串发送。 另外,您可以显式指定内容类型标头'Content-Type': 'application/json'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM