Post array of strings to web API method

前端 未结 7 1291
伪装坚强ぢ
伪装坚强ぢ 2021-02-14 14:42

this is my client side ajax call:

    var list = [\"a\", \"b\", \"c\", \"d\"];

    var jsonText = { data: list };

    $.ajax({
        type: \         


        
7条回答
  •  无人及你
    2021-02-14 15:08

    In the backend, you could use FormDataCollection.GetValues(string key) to return an array of strings for that parameter.

    public HttpResponseMessage UpdateStatusToDelete(FormDataCollection formData) {
        string[] data = formData.GetValues("data");
        ...
    }
    

提交回复
热议问题