【发布时间】:2015-11-17 12:01:06
【问题描述】:
我创建 JSON 并将其从 cilent 发送到 web api 方法。但我在端点函数中得到 NULL。
我有这个功能:
function genarateDirectives(workPlanServise) {
var dataObj = {
name: 'name',
employees: 'employee',
headoffice: 'master'
};
return workPlanServise.generateFilter(dataObj)
.then(function (result) {
return result.data;
});
}
这是我使用的服务:
(function () {
"use strict";
angular.module("workPlan").factory("workPlanServise", ["$http", "config", workPlanServise]);
function workPlanServise($http, config) {
var serviceUrl = config.baseUrl + "api/workPlan/";
var service = {
getAll: getAll,
getSubGridContent: getSubGridContent,
generateFilter:generateFilter
};
return service;
function getAll() {
return $http.get(serviceUrl);
}
function getSubGridContent(clientId) {
return $http.get(serviceUrl + '?clientId=' + clientId);
}
function generateFilter(objData) {
return $http.post(serviceUrl, objData );
}
}
})();
这里端点web api函数:
[HttpPost]
public async Task<IHttpActionResult> Post([FromBody]string objData)
{
try
{
return null;
}
catch (Exception)
{
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
}
}
知道为什么 objData 总是为空吗?
【问题讨论】:
标签: angularjs asp.net-mvc asp.net-web-api asp.net-web-api2