HttpFileCollectionBase Isnull在回发上的值

时间:2015-11-26 16:30:28

标签: asp.net-mvc-4 httpfilecollection

我好奇而不是使用HTTPFileWrapper,我使用HttpFileCollectionBase属性创建了一个模型。

var add_content = $("[add_content='add_content']").val();
var edit_content = $("[edit_content='edit_content']").val();

}

我的观点

var add_content = 0;
var edit_content = 0;
if($("#add_content").is(":checked")){
add_content = 1;

}
if($("#edit_content").is(":checked")){
edit_content = 1;
}

我的Controller for postback

public class UserLoginModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }

[Required]
[DataType(DataType.Password)]
[Display(Name = "password")]
public string Password { get; set; }


public HttpFileCollectionBase Resume { get; set; }

但是当我在控制器上检查model.Resume的值时,该值为null。可能是什么原因?感谢

1 个答案:

答案 0 :(得分:1)

你使用了错误的课程。您的财产必须是HttpPostedFileBase

public class UserLoginModel
{
    ....
    public HttpPostedFileBase Resume { get; set; }
}
相关问题