kendo UI Razor 页面异步上传 returns 404

kendo UI asynchronous uplaod on Razor Page returns 404

我正在尝试在 Razor 页面(无控制器)上使用 Kendo UI 异步上传,但出现 404 错误

Index.cshtml 页-

<div class="row">
    <div class="">
        <form asp-action="" class="" id=""  enctype="multipart/form-data">
            <div class="form-group">
                <label class="">Review Type</label>
                <div class="">               
                    <select asp-for="ReviewType" asp-items="@(new SelectList(Model.ReviewTypes, "ReviewTypeLookupId", "ReviewTypeName"))" class="form-control"></select>
                </div>
            </div>
            <div class="form-group">
                <label class=""></label>
                <div class="">
                    @(Html.Kendo().Upload()
                          .Name("files")
                          .Async(a => a
                            .Save("Index?handler=Save", "UploadManagement")
                              .Remove("Remove", "UploadManagement/Index")
                              .AutoUpload(true)
                          )
                          )
                </div>
            </div>
            <div class="form-group">
                <button type="submit" id="submit-all" class="btn btn-default">Upload </button>
            </div>
        </form>
    </div>  

Index.cshtml.cs 页面

 [HttpPost]
        public ActionResult OnPostSave(IEnumerable<IFormFile> files)
        {
            // The Name of the Upload component is "files"
            if (files != null)
            {
                foreach (var file in files)
                {
                    //var fileContent = ContentDispositionHeaderValue.Parse(file.ContentDisposition);

                    //// Some browsers send file names with full path.
                    //// We are only interested in the file name.
                    //var fileName = Path.GetFileName(fileContent.FileName.Trim('"'));
                    //var physicalPath = Path.Combine(HostingEnvironment.WebRootPath, "App_Data", fileName);

                    //// The files are not actually saved in this demo
                    ////file.SaveAs(physicalPath);
                }
            }

            // Return an empty string to signify success
            return Content("");
        }

错误 - 加载资源失败:服务器响应状态为 404(未找到)

解决此问题的最简单方法是不使用 .Save(string action, string controller) 或任何重载,而是 .SaveUrl(string url):

@(Html.Kendo().Upload()
    .Name("files")
    .Async(a => a
        .SaveUrl("./Index?handler=Save")
        .AutoUpload(true)
))

如果您在 non-default 区域并且页面本身的 url 实际上是 /area-url/Index?handler=foo

,这也有效