R
R
Roman Prokopiev2018-02-15 12:03:11
JavaScript
Roman Prokopiev, 2018-02-15 12:03:11

How to write two parameters in the body of an HTTP request?

There is a method in the controller

[HttpPost]
[Route("get-list")]
public IActionResult GetAllList([FromBody] int begin, [FromBody] int amount)
{
   ....
}

How can I write "begin" and "amount" to the request body from JS?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-02-15
@romik74

More or less like this:

$.ajax({
                    url: 'get-list'
                    type: 'POST',
                    data: { 'begin': 1, 'amount': 2},
                    dataType: 'text',
                    cache: false
                })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question