现在使用asp.net web api2.0从IOS上传图片,问题是我还想传一些用户信息比喻说用户ID
Result UploadHeadImage([FromBody] LoginUserModel model)
{
}
public class LoginUserModel
{
public int UserId { get; set; }
public string TokenId { get; set; }
}
IOS端怎样设置才能付值LoginUserModel,或者.net客户端怎能设置,下面是我的例子
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost/Fitness.WebUI/");
client.DefaultRequestHeaders.Add("qhapi", "xiong");
#region
LoginUserModel model=new LoginUserModel();
model.UserId = 1;
model.TokenId = "dfdfdfd";
MediaTypeFormatter jsonFormatter = new JsonMediaTypeFormatter();
HttpContent content = new ObjectContent<LoginUserModel>(model, jsonFormatter);
MultipartFormDataContent form = new MultipartFormDataContent();
form.Add(new StringContent("1"), "UserId");
// form.Add(new StringContent("asasasasasa"), "TokenId");
StreamContent fileContent = new StreamContent(File.OpenRead(@"J:\3_03c1bf119bba2642232978cfead8e239_212.jpg"));
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
fileContent.Headers.ContentDisposition.FileName = "3_03c1bf119bba2642232978cfead8e239_212.jpg";
form.Add(fileContent);
#endregion
HttpResponseMessage res = client.PostAsync("api/v1/User/UploadHeadImage", form).Result;
var uploadModel = res.Content.ReadAsStringAsync().Result;
请问那里有问题,谢谢