Reputation: 107
I work on project which contains 2 controllers with same name in different namespaces
Web.Mvc.Areas.Company.Controllers
{
public class TestController {}
}
Web.Mvc.Areas.Employment.Controllers
{
public class TestController {}
}
I need to send the file by ajax to TestController in Employment namespace
$.ajax({
url: 'Test/UploadFiles',
type: "POST",
contentType: false,
processData: false,
data: fileData,
success: function(result) {
alert(result);
},
error: function(err) {
alert(err.statusText);
}
});
I'm getting error 500 after request, app found two controllers with the same name. Is there any possibility to put the correct namespace into ajax request?
Upvotes: 0
Views: 48
Reputation: 4833
$.ajax({
url: '/Employment/Test/UploadFiles',
type: "POST",
contentType: false,
processData: false,
data: fileData,
success: function(result) {
alert(result);
},
error: function(err) {
alert(err.statusText);
}
});
or event better if you can inject Razor syntax:
$.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);
}
});
Upvotes: 4