Asp.net 使用Ajax请求在MVC中上传Excel文件
我正在尝试使用Ajax请求上载Excel文件 这是我的代码:Asp.net 使用Ajax请求在MVC中上传Excel文件,asp.net,excel,ajax,model-view-controller,Asp.net,Excel,Ajax,Model View Controller,我正在尝试使用Ajax请求上载Excel文件 这是我的代码: $.ajax({ url: "/Configuration/ImportCPTMappingWithApptType", type: "POST", contentType: false, processData:
$.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。可能是什么问题?找不到名为“配置”的控制器,该控制器的方法为“ImportCPTMappingWithApptType”,该方法的属性为[HttpPost] 您需要检查路由,以找到方法的正确名称 一个老掉牙但很好的帮手是一个通病
当您在dev机器上运行时,它将为您提供项目中所有路由的详细信息,以及哪些路由(如果有的话)与路径匹配。同样的ajax在HttpGet上运行良好。