【问题标题】:Excel File Upload in MVC Using Ajax request使用 Ajax 请求在 MVC 中上传 Excel 文件
【发布时间】:2020-04-12 21:06:19
【问题描述】:

我正在尝试使用 Ajax 请求上传 Excel 文件。

这是我的代码:

$.ajax({
                            url: "/Configuration/ImportCPTMappingWithApptType",
                            type: "POST",
                            contentType: false,
                            processData: false,
                            data: data1,
                            success: function (Message) {
                                Console.log(Message);
                                //$("#Products").html(Message);
                            },
                            failure: function (response) {
                                fnClosePageLoader();
                                fnErrormsg(response.responseText);
                            },
                            error: function (xhr, status, p3, p4) {
                                var err = "Error " + " " + status + " " + p3 + " " + p4;
                                if (xhr.responseText && xhr.responseText[0] == "{")
                                    err = JSON.parse(xhr.responseText).Message;
                                fnErrormsg(err);
                                alert(err);
                                return false;
                            }
                        });

但它会引发错误 404 Not Found。可能是什么问题?

【问题讨论】:

  • 相同的 ajax 与 HttpGet 一起工作正常。

标签: asp.net excel ajax model-view-controller


【解决方案1】:

没有找到名为“Configuration”的控制器,其方法为“ImportCPTMappingWithApptType”,其属性为 [HttpPost]

您需要检查您的路线以找到该方法的正确名称。

RouteDebugger 是一个老派但很好的帮手 https://www.nuget.org/packages/routedebugger

当您在开发机器上运行时,将为您提供项目中所有路由的详细信息以及哪些(如果有)与路径匹配。

【讨论】:

    猜你喜欢
    • 2011-08-20
    • 1970-01-01
    • 2015-04-05
    • 2015-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-12
    • 1970-01-01
    相关资源
    最近更新 更多