我在项目中工作,该项目包含2个不同命名空间中具有相同名称的控制器
ng-repeat="res in details"
ng-repeat="res in response.data"
ng-repeat="res in data"
ng-repeat="res in response"
ng-repeat="res in response.data.Results"
ng-repeat="res in details.data.Results"
我需要通过ajax将文件发送到Employment namespace
中的TestControllerWeb.Mvc.Areas.Company.Controllers
{
public class TestController {}
}
Web.Mvc.Areas.Employment.Controllers
{
public class TestController {}
}
我在请求后收到错误500,app发现两个名字相同的控制器。是否有可能将正确的命名空间放入ajax请求中?
答案 0 :(得分:4)
$.ajax({
url: '/Employment/Test/UploadFiles',
type: "POST",
contentType: false,
processData: false,
data: fileData,
success: function(result) {
alert(result);
},
error: function(err) {
alert(err.statusText);
}
});
如果你可以注入Razor语法,那么或更好的事件:
$.ajax({
url: '@Url.Action("UploadFiles", "Test", new {area = "Employment"})',
type: "POST",
contentType: false,
processData: false,
data: fileData,
success: function(result) {
alert(result);
},
error: function(err) {
alert(err.statusText);
}
});
答案 1 :(得分:0)