Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc Razor页面上的剑道UI异步上传返回404_Asp.net Mvc_Asp.net Core_Kendo Asp.net Mvc_Razor Pages - Fatal编程技术网

Asp.net mvc Razor页面上的剑道UI异步上传返回404

Asp.net mvc Razor页面上的剑道UI异步上传返回404,asp.net-mvc,asp.net-core,kendo-asp.net-mvc,razor-pages,Asp.net Mvc,Asp.net Core,Kendo Asp.net Mvc,Razor Pages,我试图在Razor页面上使用剑道UI异步上传(没有控制器),但我得到404错误 Index.cshtml页面- <div class="row"> <div class=""> <form asp-action="" class="" id="" enctype="multipart/form-data"> <div class="form-group"> <l

我试图在Razor页面上使用剑道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>  

评论类型
@(Html.Kendo().Upload())
.Name(“文件”)
.Async(a=>a
.Save(“索引?处理程序=保存”,“上载管理”)
.Remove(“Remove”,“UploadManagement/Index”)
.自动上载(真)
)
)
上传
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("");
        }
[HttpPost]
PostSave上的公共操作结果(IEnumerable文件)
{
//上载组件的名称为“文件”
如果(文件!=null)
{
foreach(文件中的var文件)
{
//var fileContent=ContentDispositionHeaderValue.Parse(file.ContentDisposition);
////有些浏览器发送带有完整路径的文件名。
////我们只对文件名感兴趣。
//var fileName=Path.GetFileName(fileContent.fileName.Trim(“”);
//var physicalPath=Path.Combine(HostingEnvironment.WebRootPath,“应用程序数据”,文件名);
////这些文件实际上并未保存在此演示中
////file.SaveAs(物理路径);
}
}
//返回一个空字符串表示成功
返回内容(“”);
}
错误-
加载资源失败:服务器响应状态为404(未找到)

解决此问题的最简单方法是不使用
.Save(字符串操作,字符串控制器)
或任何重载,而是
.SaveUrl(字符串url)


如果您位于非默认区域,并且页面本身的url实际上是
/area url/Index?handler=foo

,那么这也会起作用。对于razor页面,您需要将路径设置为Index?handler=Save并将操作名称更改为OnPostSave?这样做。但我仍然得到404。请查看更新的代码。呈现页面时,url显示什么?如果hat path是有效的,那么问题一定是模型绑定。我不太熟悉w/razor页面,但是您不需要
BindProperty
属性吗?这也在中讨论过。
@(Html.Kendo().Upload()
    .Name("files")
    .Async(a => a
        .SaveUrl("./Index?handler=Save")
        .AutoUpload(true)
))