Asp.net mvc 具有多个HttpPostedFileBase属性的MVC模型

Asp.net mvc 具有多个HttpPostedFileBase属性的MVC模型,asp.net-mvc,vb.net,asp.net-mvc-3,file-upload,Asp.net Mvc,Vb.net,Asp.net Mvc 3,File Upload,我在get/post操作中使用以下模型 Public Class AuthorEditQuestionViewModel <Required()> <Display(Name:="Question Title")> Public Property Title As String <Display(Name:="Start Ledger")> Public Property StartLedger As HttpPos

我在get/post操作中使用以下模型

Public Class AuthorEditQuestionViewModel

    <Required()>
    <Display(Name:="Question Title")>
    Public Property Title As String

    <Display(Name:="Start Ledger")>
    Public Property StartLedger As HttpPostedFileBase
    Public Property StartLedgerUrl As String

    <Display(Name:="End Ledger")>
    Public Property EndLedger As HttpPostedFileBase
    Public Property EndLedgerUrl As String

    <Required()>
    <Display(Name:="Introduction/Instructions")>
    Public Property IntroductionHtml As String

End Class

快速测试表明它工作正常。您好吗?您的BeginForm方法是什么样子的?添加了更多。。当我调试控制器时,我只在第一个文件输入中附加了一个文件,但是action方法看到了这两个属性的ContentLength。。。现在它似乎运行正常/您的代码看起来与我模拟的代码非常相似。MVC3通常非常擅长绑定。但很高兴看到它起作用了。
<input type="file" id="StartLedger" name="StartLedger" />
<input type="file" id="EndLedger" name="EndLedger" />
@Using Html.BeginForm("EditQuestion", "Author", Nothing, FormMethod.Post, New With {.enctype = "multipart/form-data"})

    @Html.ValidationSummary("Please correct the following issues.")

    @<table class="form">
        <tr>
            <td class="label">@Html.LabelFor(Function(m) m.Title)</td>
            <td class="input">
                @Html.TextBoxFor(Function(m) m.Title)
            </td>
        </tr>
        <tr>
            <td class="label">@Html.LabelFor(Function(m) m.StartLedger)</td>
            <td class="input">
                <input type="file" id="StartLedger" name="StartLedger" />
                @If Not String.IsNullOrWhiteSpace(Model.StartLedgerUrl) Then
                    @<a href="@Model.StartLedgerUrl">Download</a>
                End If
            </td>
        </tr>
        <tr>
            <td class="label">@Html.LabelFor(Function(m) m.EndLedger)</td>
            <td class="input">
                <input type="file" id="EndLedger" name="EndLedger" />
                @If Not String.IsNullOrWhiteSpace(Model.EndLedgerUrl) Then
                    @<a href="@Model.EndLedgerUrl">Download</a>
                End If
            </td>
        </tr>
        <tr>
            <td class="label" colspan="2">@Html.LabelFor(Function(m) m.IntroductionHtml)</td>
        </tr>
        <tr>
            <td class="input" colspan="2">@Html.TextAreaFor(Function(m) m.IntroductionHtml, 10, 80, Nothing)</td>
        </tr>
        <tr>
            <td class="buttons" colspan="2">
                <button class="action" data-action="@Url.Action("Index")">Cancel</button>
                <button>Save</button>
            </td>
        </tr>
    </table>


End Using
Function EditQuestion(id As Guid?, model As AuthorEditQuestionViewModel) As ActionResult