【发布时间】:2014-12-22 13:17:07
【问题描述】:
我通过传入序列化的 JSON DTO 来调用 webapi 上的发布操作。
我还有一个自定义媒体类型格式化程序来加密结果数据。但是在 WriteToStreamAsync 方法中,如何获取发布的参数?
自定义媒体类型格式化程序类
public class JsonFormatter : JsonMediaTypeFormatter
{
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
{
var taskSource = new TaskCompletionSource<object>();
try
{
if (value != null)
{
//How to get posted parameters?
}
}
catch (Exception e)
{
taskSource.SetException(e);
}
return taskSource.Task;
}
}
}
【问题讨论】:
标签: json asp.net-web-api asp.net-web-api2