Kni*_*Fox 3 .net c# url post serialization
在请求方,我的代码如下所示
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
Run Code Online (Sandbox Code Playgroud)
在接收端,我希望我的控制器方法是
[HttpPost]
public void MyMethod(List<int> myList)
{
\\ Doing stuff here
}
Run Code Online (Sandbox Code Playgroud)
你可以尝试这样做:
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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1435 次 |
| 最近记录: |