[沒有蠢問題] Ajax.BeginForm 上傳檔案 失敗

今天鬼打牆好久 紀錄一下防止下次再犯

 @using (Ajax.BeginForm("CsvFile", "TestItem",null,
                  ajaxOptions: new AjaxOptions
                  {
                      HttpMethod = "Post",
                      OnSuccess = "OnSuccess",
                      OnFailure = "OnFailure",
                      OnBegin = "HoldOnOpen()",
                      OnComplete = "HoldOnClose"
                  },
                  htmlAttributes: new { id = "UploadForm", enctype = "multipart/form-data" }))
            {
                <div class="box-body">
                    @Html.AntiForgeryToken()
                    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                    <div class="form-group">
                        <label for="exampleInputFile">上傳csv檔案</label>
                        <input type="file" id="dataFile" name="upload" />
                        <p class="help-block">Example block-level help text here.</p>
                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="submit" class="btn btn-primary">Submit</button>
                </div>
            }
[HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult ImportRecommendItemByCsv(HttpPostedFileBase upload)
        {

input 的 name = "upload" 要跟 action 的 HttpPostedFileBase upload  要同名

因為不同名 所以一直是null 

如果內容有誤請多鞭策謝謝