Die übergabe eines HttpPostedFileBase zu einer controller-Methode

Ich versuche nur, um ein Formular erstellen, wo ich einen Namen eingeben und eine Datei hochladen. Hier ist das view-model:

public class EmployeeViewModel
{
    [ScaffoldColumn(false)]
    public int EmployeeId { get; set; }

    public string Name { get; set; }

    public HttpPostedFileBase Resume { get; set; }
}

Meiner Sicht:

@using (Html.BeginForm("Create", "Employees", FormMethod.Post))
{   
    @Html.TextBoxFor(model => model.Name)

    @Html.TextBoxFor(model => model.Resume, new { type = "file" })

    <p>
        <input type="submit" value="Save" />
    </p>

    @Html.ValidationSummary()
}

Und meine controller-Methode:

[HttpPost]
public ActionResult Create(EmployeeViewModel viewModel)
{
    //code here...
}

Das problem ist, dass wenn ich die post an die controller-Methode, die Resume-Eigenschaft ist null. Die Name-Eigenschaft übergeben bekommt ganz gut, aber nicht das HttpPostedFileBase.

Mache ich etwas falsch hier?

InformationsquelleAutor Steven | 2012-03-01
Schreibe einen Kommentar