On the requester side my code looks like following
var myList = new List<int> {1,2,3};
var content =
new FormUrlEncodedContent
(
new KeyValuePair<string, string>[]
{
KeyValuePair.Create("myList", myList.ToString())
}
);
//Make Post Request here
On the receiver end I want my controller method to be
[HttpPost]
public void MyMethod(List<int> myList)
{
\\ Doing stuff here
}
You can try to do:
var myList = new List<int> { 1, 2, 3 };
var myPostData = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("myList", string.Join(",", myList))
};
var content = new FormUrlEncodedContent(myPostData);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.