将带有文件附件的表单发布到单轨控制器

时间:2010-03-26 14:38:08

标签: forms castle-monorail

我有以下表格(brail):

<form method="post" enctype="multipart/form-data" action="${UrlHelper.For({@action:'Upload'})}">
<p><b>Select Template:</b> &nbsp;
  <select id="template">
        <option selected>Select One..</option>
        <option value="Research">Research</option>
    </select>
</p>
<br/>
<p><b>Download Worksheet:</b> &nbsp; <a id="downloadLink">Worksheet</a></p>
<br/>
<p><b>Research Item Upload</b></p>
  <fieldset>
    <legend>Upload Research Items File</legend>

    <label for="file">File</label>
    <input type="file" name="file" size="80" accept="application/vnd.ms-excel,application/excel,application/x-msexcel" />
    <br />

    <input type="submit" value="Upload" />
  </fieldset>
</form>

在我的控制器上发布了以下方法签名:

[AccessibleThrough(Verb.Post)]
public UploadResults Upload(string template, [HttpPostedFileAdapterBinder] IHttpPostedFileAdapter file) {}

当我发布表单时,我只收到该文件。模板var为null,我不知道为什么。有没有人看到我遗失的明显事物?

1 个答案:

答案 0 :(得分:1)

您错过了name上的<select>属性:

<select name="template" id="template">
...
</select>