【发布时间】:2013-12-10 11:26:01
【问题描述】:
我有一个自定义的 dto 类:
public class myObject
{
public string Id { get; set; }
public string Name { get; set; }
}
和一个使用 Web Api(4.5 .net 框架)的控制器
[HttpPost]
public IHttpActionResult StripArchiveMailboxPermissions(myObject param)
{
DoSomething(param);
return OK();
}
客户端只有 4.0 .net 框架所以我将无法使用 PostAsJsonAsync() 方法。将对象从我的客户端传递到服务器的解决方案是什么?
我尝试过类似以下的方法:
var response = Client.SendAsync(new HttpRequestMessage<myObject>(objectTest)).Result;
但是它给我抛出了异常:
Could not load file or assembly 'Microsoft.Json, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The system cannot find the file specified.
难道不能使用 Newtonsoft.Json 库吗?
【问题讨论】:
标签: c# asp.net-web-api dotnet-httpclient