【问题标题】:Does the Nancy model binder work with properties of type HttpFile?Nancy 模型绑定器是否适用于 HttpFile 类型的属性?
【发布时间】:2013-07-25 06:52:25
【问题描述】:

Nancy 中的模型绑定器(通过 Nancy.ModelBinding 中定义的类型 NancyModule 的扩展方法 Bind 调用)适用于原语类型(例如 string),但似乎忽略了 HttpFile 类型的属性。所以如果这是我的模型:

class MyModel
{
    public string Name { get; set; }    // <- successully binds
    public HttpFile Image { get; set; } // <- ignored
}

那么Name会绑定成功,但Image就不行了。检查 NancyModule 上的 NancyRequest 对象确实有一个包含我想要的文件的 Files 属性;它只是没有被活页夹复制到我的模型中。这应该只是工作,还是我必须编写自定义代码才能使其工作。如果有,怎么做?

干杯

【问题讨论】:

    标签: model-binding nancy


    【解决方案1】:

    不,它不绑定文件。如果你愿意,你可以增加它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-26
      • 2010-11-30
      • 2015-01-23
      相关资源
      最近更新 更多