为什么API方法从未被解雇?

时间:2015-11-24 13:47:23

标签: angularjs asp.net-web-api2 asp.net-web-api

我有这个API方法:

namespace Playground.Web.Controllers.API
{
    public class FilterConfigurationsController : ApiController
    {
        private readonly PlaygroundContext _context;
        public FilterConfigurationsController()
        {
            _context = new PlaygroundContext();
        }

        [HttpPost]
        public async Task<IHttpActionResult> Post(Filter data)
        {
            try
            {
                var ere = FilterViewModel.GenerateDataForFilters(data, _context);
                return Ok(data);
            }
            catch (Exception ex)
            {
                throw;
            }
        }


        [HttpPost]
        public async Task<IHttpActionResult> Post(IEnumarable<Filter> filterDescriptionList)
        {
            try
            {
                var data = FilterViewModel.GenerateDataForFilters(filterDescriptionList, _context);
                return Ok();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _context.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}

要调用此方法,我使用此HTTP post调用:

$http.post(config.baseUrl + "api/FilterConfigurations/", scope.filterParams).then(function (result) {});

我正在开发Web API项目并在我的项目中使用AngularJS。

此HTTP帖子调用:

$http.get(config.baseUrl + "api/FilterConfigurations/,{data= scope.filterParams[0]}).then(function (result) {});

必须调用此方法API:    public async Task Post(Filter data)en(function(result){});

但上面的方法API从未被解雇过。

相反,这种方法被解雇了:

public async Task<IHttpActionResult> Post(Filter filterDescriptionList)

知道为什么API方法永远不会被解雇? 我做错了什么?

0 个答案:

没有答案