RequestDTO的属性在servicestack中给出了错误的值

时间:2015-08-21 09:24:22

标签: service f# servicestack

defmodule Test do
  def add(a, b, c) do
    a + b + c 
  end
end

apply(Test, :add, [1, 2, 3])

我正在尝试使用servicestack创建服务。 RequestDTO有两个属性(module FileUploadService = type FileDetails() = member val fileName= string with get,set interface IRequiresRequestStream with member val RequestStream = null with get,set type FileService() = inherit Service() interface IService member this.Post(request : FileDetails ) = //My Logic //can not able to read "request.fileName" property value. )。

我想读取fileName and RequestStream属性的值,它显示的值为request.fileName。我不明白为什么每次都显示ctor@25值。

编辑 - 下面的代码是在客户端编写的。  

ctor@25

1 个答案:

答案 0 :(得分:1)

当您使用IRequiresRequestStream装饰您的Request DTO时,您告诉ServiceStack不要自己taking over deserializing the Request Stream读取请求正文。但是,它仍会尝试使用请求提交的其余Request参数填充Request DTO。

如果没有看到实际的HTTP请求,我无法判断fileName是否也包含在HTTP请求中,但如果这是multipart / formdata请求,则fileNameincluded in the HTTP Headers

但如果是multipart/formdata请求请勿 use IRequiresRequestStream to read the request。 IRequiresRequestStream仅在将原始字节流发布到URL时才有意义,它不适用于处理multipart/formdata,它应使用base.Request.Files专门用于处理multipart/formdata请求,并包含对其他元数据的访问权限使用文件上传发布。

相关问题