使用 Ajax 请求在 MVC 中上传 Excel 文件



我正在尝试使用 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 未找到。可能是什么问题?

它找不到名为"Configuration"的控制器,该方法为"ImportCPTMappingWithApptType",其属性为 [HttpPost]

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

一个老式但好东西的助手是RouteDebugger https://www.nuget.org/packages/routedebugger

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

最新更新