【发布时间】:2015-02-05 20:31:48
【问题描述】:
我正在尝试将 HttpPost 请求从 Android 发送到 C# (.net 3.5) aspx 服务器。我正在使用 Apache 多部分实体构建器在 Android 端构建实体:
entityBuilder.addTextBody("username", username);
entityBuilder.addTextBody("password", password);
entityBuilder.addBinaryBody("file", file);
并尝试在 C# 服务器端获取数据:
protected void Page_Load(object sender, EventArgs e)
{
string[] keys = Request.Form.AllKeys; // only username and password keys received.
for (int i = 0; i < keys.Length; i++)
{
string [] tmp = Request.Form.GetValues (keys[i]);
}
}
我可以在请求中获取 TextBody 部分的键和值(用户名和密码)。但没有收到 BinaryBody 密钥或数据。不知道为什么?
【问题讨论】:
-
请将解决方案作为答案发布。
-
我应该在stackoverflow中回答我自己的问题吗?回答我自己的问题后,我的声誉损失了 2 分...
标签: c# asp.net .net .net-3.5 multipart