我的 WEB API 控制器中有以下 post 方法:
public async Task<HttpResponseMessage> SendPost(Application application)
我通过 javascript 调用它Angular.js $http.post
并以 JSON 形式传递应用程序参数:
$http.post("/api/AController/SendPost", JSON.stringify(application)).
success(function (data, status, headers, config) {
}
这有效。
现在我想将第二个参数作为简单字符串传递(我无法修改现有的应用程序 JSON 对象)。我尝试了网上建议的几种不同方法,但似乎都不起作用。我需要能够做这样的事情:
控制器:
public async Task<HttpResponseMessage> SendPost(RentalApplication application,string test)
JavaScript:
$http.post("/api/TessIntegration/SendPost", {application:JSON.stringify(application),test:"Some value"}).
success(function (data, status, headers, config) {
}