1

I'm performing file uploads from Javascript. The file is transferred fine, but the additional form data passed in the request is not bound to the request DTO.

From Chrome inspector:

------WebKitFormBoundaryunl7tsdqzGBvtsUH
Content-Disposition: form-data; name="albumId"

1037
------WebKitFormBoundaryunl7tsdqzGBvtsUH
Content-Disposition: form-data; name="file"; filename="Tulips.jpg"
Content-Type: image/jpeg

RequestDTO

public class UploadRequest : IRequiresRequestStream
{
    public Stream RequestStream { get; set; }
    public string FileName { get; set; }
    public long? AlbumId { get; set; }
}

The image is properly bound, but other items from form-data. What's interesting is that Request.FormData contains the entry for albumId.

Any clues ?

4

1 回答 1

1

我认为这是由于UploadRequest继承自 IRequiresRequestStream绕过表单数据到 DTO 的任何绑定的事实。

于 2013-06-14T16:07:33.087 回答